- 第一种写法
SELECT "local_events".* FROM "local_events" WHERE (event_type is not null) ORDER BY event_type='01' DESC, event_type='02' DESC
- 第二种写法
SELECT "local_events".* FROM "local_events" ORDER BY position(event_type::text in '01,02')
参考
SELECT "local_events".* FROM "local_events" WHERE (event_type is not null) ORDER BY event_type='01' DESC, event_type='02' DESC
SELECT "local_events".* FROM "local_events" ORDER BY position(event_type::text in '01,02')
参考
本文标题:Postgres 按照特定元素排序
本文链接:https://www.haomeiwen.com/subject/fzjxmttx.html
网友评论