I use SQL Server 2008 R2.
SQL Server 2008 R2
I need to sort a table by the minimal value of two columns.
The table looks like this:
ID: integer; Date
I prefer this way to handle nullable columns:
SELECT Id, Date1, Date2 FROM YourTable ORDER BY CASE WHEN Date1 < Date2 OR Date1 IS NULL THEN Date1 ELSE Date2 END