热线电话:13121318867

登录
2019-02-25 阅读量: 812
SQL查询排序OrderBy

问题描述:

1.我要查询课程排序,有三种状态:正在上课、即将上课、已结束
2.大排序按,正在上课、即将上课、已结束
3.小排序,正在上课、即将上课(按时间正序),已结束(按时间倒序)

如何在一个SQL中实现?

解决方法:

正在上课、即将上课、已结束 对应status 1,2,3

select *from table order by status,case status when 1 then sorttime end asc,case status when 2 then sorttime end asc,case status when 3 then sorttime end desc;
42.8571
1
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子