我现在有两个字段 addDay(添加时间)和status(状态)。
我想要实现以下排序方式:
1.按addDay降序排列,并且status升序排列且status2.把status>=6的放在规则1的后面,并且按addDay降序和status升序排列
addDay status
2016-4-14 1
2016-4-14 2
2016-4-13 1
2016-4-13 2
2016-4-14 6
2016-4-13 6
请问各位大神,这样的排序,应该如何写sql语句?
select addDay,status from table where status < 6 order by addDay desc,status ascunion allselect addDay,status from table where status >= 6 order by addDay desc,status asc
order by case when status<6 then addDay else 1 end desc,status asc
order by case when status<6 then addDay else 1 end desc,addDaydesc,status asc
select * from table order by if(status<6 , 1, 0 ) desc, addDay desc,status asc
select * from tbl_name order by status>=6, addDay desc, status asc
谢谢各位了,问题已经解决了