Postgres 按照特定元素排序

2016-12-01  本文已影响8人  sbtiny
  1. 第一种写法
SELECT "local_events".* FROM "local_events" WHERE (event_type is not null) ORDER BY event_type='01' DESC, event_type='02' DESC
  1. 第二种写法
SELECT "local_events".* FROM "local_events" ORDER BY position(event_type::text in '01,02')

参考

上一篇 下一篇

猜你喜欢

热点阅读