我有这张 table
id value
1 OK
2 xminimum
3 NO
4 YES
我想按 value
对这个表进行排序,其中 minimum
始终排在第一位,然后根据 value
列的字母顺序排序其余部分
含义:
xminimum
NO
OK
YES
我写了这个查询:
Select *
from table_a
order by case when value='xminimum' then 1 else ????? end
我不知道在 else 中放什么...从概念上讲它应该是 else value end
所以它意味着字母顺序..但我不能将整数与文本结合起来。
我该如何解决?
最佳答案
根据要求,从我的评论中复制:
Select *
from table_a
order by case when value='xminimum' then 1 else 2 end, value
关于sql - 如何在 PostgreSQL 中对整数和文本的组合进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41587450/