Skip to content

Instantly share code, notes, and snippets.

@brazilnut2000
Last active December 15, 2015 23:09
Show Gist options
  • Save brazilnut2000/5338080 to your computer and use it in GitHub Desktop.
Save brazilnut2000/5338080 to your computer and use it in GitHub Desktop.
SQL: Sort nulls in your result set.
/*
* 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