tsql - SQL Server : sorting NULL Marks with ORDER BY clause -
i have query :
select orderid, shippeddate sales.orders custid = 20 order shippedate; and output is:
orderid shippeddate ------- ----------- 11008 null 11072 null 10258 2006-07-23 00:00:00.000 10263 2006-07-31 00:00:00.000 10351 2006-11-20 00:00:00.000 10368 2006-12-02 00:00:00.000 ... as exercise, trying figure out how sort orders shippeddate ascending, have nulls sort last.
i know standard sql support options null first , null last, t-sql doesn't support option.
any suggestions?
thanks
you can this:
select orderid, shippeddate sales.orders custid = 20 order case when shippeddate null 2 else 1 end, shippedate;
Comments
Post a Comment