【20180517】SQLServer排序问题

//排序,把LocName是ABC或者Name是ABC的优先级提升
select * from SuppCountries where Valid=1 order by case when LocName like '%ABC%' or Name like '%ABC%' then 1 end desc
//排序,把状态是1的优先级提升,再按照时间排序
select * from UserCoupons where UserID='lfx001' order by case when Status=1 then 1 end desc,ReceivedTime desc

猜你喜欢

转载自blog.csdn.net/qq_36205380/article/details/80351731