TSQL ORDER BY with nulls first or last (at bottom or top)

后端 未结 4 1290
被撕碎了的回忆
被撕碎了的回忆 2020-12-24 06:58

I have a date column which has some NULL. I want to order by the date column ASC, but I need the NULL s to be at the bottom. How to do it on

4条回答
  •  粉色の甜心
    2020-12-24 07:11

    Select *
     From  YourTable
     Order By case when DateCol is null then 0 else 1 end
             ,DateCol
    

    Or even Order By IsNull(DateCol,'2525-12-31')

提交回复
热议问题