运行此查询:
select name from folders order by name
返回这些结果:
alphanumeric
a test
test 20
test 19
test 1
test 10
但我预计:
a test
alphanumeric
test 1
test 10
test 19
test 20
这里有什么问题吗?
最佳答案
您可以简单地将 name
列转换为 bytea
允许整理不可知排序的数据类型:
SELECT name
FROM folders
ORDER BY name::bytea;
结果:
name
--------------
a test
alphanumeric
test 1
test 10
test 19
test 20
(6 rows)
关于Postgresql 排序混合字母数字数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7018628/