Showing posts with label sort. Show all posts
Showing posts with label sort. Show all posts

Wednesday, August 14, 2013

SQL SELECT Ordering columns with Null Values

...or in order to avoid value clashing...
SELECT 
   ColumnA, 
   ColumnB
FROM YourTable
ORDER BY 
   CASE WHEN ColumnB IS NULL THEN 1 ELSE 0 END ASC,
   ColumnB