select * from test order by case when to_char(time,'yyyy-mm-dd hh24:mi:ss')='1977-01-01 00:00:00' then 0 else 1 end asc,test.time asc
then 0 else 1end排序
本文介绍了一种使用SQL的CASE WHEN语句进行复杂排序的方法。通过一个具体的示例,展示了如何根据特定的时间格式来调整记录的排序顺序。这种方法适用于需要根据自定义逻辑对数据进行排序的情况。
select * from test order by case when to_char(time,'yyyy-mm-dd hh24:mi:ss')='1977-01-01 00:00:00' then 0 else 1 end asc,test.time asc
then 0 else 1end排序
1057

被折叠的 条评论
为什么被折叠?