Last active
January 6, 2016 05:56
-
-
Save andersondias/2fa15022b839ba9a752d to your computer and use it in GitHub Desktop.
Ordering by nulls on Postgres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Default order will return NULL values at | |
-- the end of list | |
SELECT value FROM example ORDER BY value; | |
------------ | |
-- value -- | |
------------ | |
-- 1 -- | |
-- 2 -- | |
-- 3 -- | |
-- NULL -- | |
------------ | |
-- Ordering using the NULLS FIRST option will return | |
-- the list with NULL values in the beginning. | |
SELECT value FROM example ORDER BY value NULLS FIRST; | |
------------ | |
-- value -- | |
------------ | |
-- NULL -- | |
-- 1 -- | |
-- 2 -- | |
-- 3 -- | |
------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment