SQL Server equivalent to Oracle's NULLS FIRST?

前端 未结 8 583
心在旅途
心在旅途 2020-12-08 00:50

So Oracle has NULLS FIRST, which I can use to have null values sorted at the top followed by my column value in descending order:

ORDER BY date_sent NULLS FI         


        
8条回答
  •  萌比男神i
    2020-12-08 01:14

    This is an alternative way when you want to adjust how nulls appear in the sort order. Negate the column and reverse your sort order. Unfortunately you would need to CAST dateTime columns.

    ORDER BY -CAST(date_sent as int) ASC
    

提交回复
热议问题