Last active
December 15, 2015 23:09
-
-
Save brazilnut2000/5338080 to your computer and use it in GitHub Desktop.
SQL: Sort nulls in your result set.
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
/* | |
* Sort nulls in your result set. | |
*/ | |
SELECT * FROM myTable | |
WHERE ... | |
ORDER BY CASE WHEN myCol IS NULL THEN 1 ELSE 0 END, myCol; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment