sql server中如何让空值排最后

请看Demo代码

declare @table table( id int identity  primary  key , 
date1 datetime, 
name char(10), 
type1 int )   

insert into @table 
select Null, 'angelia',0 
union all 
select getdate(), 'Nathan',0 
union all 
select getdate()+1, 'Nathan1',0 
union all 
select getdate()+2, 'Nathan2',0 

select * 
from @table 
order by case when date1 is null then 1 else 0 end, date1 


阅读更多
个人分类: SQL Server
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭