LoginSignup
20

More than 5 years have passed since last update.

PostgreSQLのソートで、nullの位置を制御する

Posted at

PostgreSQLのORDER BYで
ORDER BY some_time DESC NULLS LAST
と「NULLS LAST」書くと NULLが下に来るように制御できた。

some_time
----------
2015-07-01
2015-06-21
2015-05-15

・・・

null
null

みたいな結果になる。
デフォルトだとNULLS FIRSTになって、NULLが上に来る。

普通に考えると、降順でNULLが一番下に来そうだけどな。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20