开发者

complex sorting sql

I have the following table

Priority  Time
100        1
 86        3
 85        2 

I want to sort it by first by priority and then by time, however, priority differce within 20 points are treated the same. e.g. 100 and 85 are considered as the same priority level. so the result will be:

Priority  Time
    100开发者_如何学Go        1
     85        2
     86        3 

Thanks,


Try this (assuming that priority is an integer)

select * 
from foobar
order by ( priority / 20 ) , -- 0-19 yields 0 , 20-39 yields 1, etc.
         time
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜