我是postrges的新手,想要对varchar类型的列进行排序。以下示例将说明问题:
表名:testsorting
order name
1 b
2 B
3 a
4 a1
5 a11
6 a2
7 a20
8 A
9 a19
大小写敏感排序(在postgres中是默认的)会给出:
select name from testsorting order by name;
A
B
a
a1
a11
a19
a2
a20
b
不区分大小写的排序结果如下:
select name from testsorting order by UPPER(name);
A
a
a1
a11
a19
a2
a20
B
b
如何在Postgres中进行字母数字大小写不敏感的排序,以获得以下顺序::
a
A
a1
a2
a11
a19
a20
b
B
我不会介意大小写字母的顺序,但顺序应为"aAbB"或"AaBb",而不应为"ABab"。
如果您在PostgreSQL中有任何解决方案,请提出建议。