34
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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が一番下に来そうだけどな。

34
20
0

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
34
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?