Table has a nullable ContactDate field. I want to sort these records so that non-null values come first in ascending order and then null values are sorted after non-nullable values.
Select * from myTable Order by ContactDate ASC
returns following
NULL
NULL
NULL
NULL
2015-07-27 10:00:00.000
2015-07-29 10:00:00.000
then,
Select * from myTable Order by ContactDate DESC
returns following
2015-07-29 10:00:00.000
2015-07-27 10:00:00.000
NULL
NULL
NULL
NULL
But I need it like this:
2015-07-27 10:00:00.000 -- asc
2015-07-29 10:00:00.000 -- asc
NULL
NULL
NULL
NULL
Using MS SQL Server 2012