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

后端 未结 4 1304
被撕碎了的回忆
被撕碎了的回忆 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:08

    order by case when col_name is null then 1 else 2 end, col_name asc did the trick on Oracle. However the same on MS SQL Server pushes the NULL records down leaving non null to be on top of the result set.

提交回复
热议问题