- Like
ORDER BY with CASE -Statement- first group: null values ββin the
Col1 date column Col2 DESC date column - second group: non-zero values ββin date-column-
Col1 , sorted by Col1 DESC
I tried the following:
SELECT columns FROM tables WHERE condition ORDER BY case when Table1.Col1 IS NULL then 0 end, Table2.Col2 DESC, case when Table1.Col1 IS NOT NULL then 1 end, Table1.Col1 DESC
But the sort order is wrong, first NOT NULL values ββ(sorted by Col2 instead of Col1). I think I missed the detail.
source share