您的位置:首页 > 数据库

sql排序 根据字段内容,以及根据内容进行计算排序

2017-01-03 17:51 239 查看
1,当前时间与字段时间进行对比,分三种情况然后排序

2,根据字段具体值,进行排序

SELECT  * from 表名(table)
order by
case when
table.start <='2017-01-03' AND table.end  >='2017-01-03' then 1
when table.end <'2017-01-03' then 2
when table.start is null  AND table.end is null then 3
end,
case when table.type=1 then 1
when table.type=3 then 2
when table.type=2 then 3
when table.type=4 then 4
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sql 排序