Reputation: 1977
I need to sort this table by hour, from 19 to 18 next day.
Hour HourCount
0 234
1 322
2 333
3 433
4 544
5 589
6 675
7 688
8 734
9 789
10 821
11 892
12 922
13 954
14 987
15 996
16 1007
17 1068
18 1121
19 0
20 36
21 78
22 126
23 189
How can I do it? Is there any method that I can order by set of numbers?
Upvotes: 0
Views: 31
Reputation: 28413
SELECT *
FROM TABLE1
ORDER BY CASE WHEN HOUR > 17 THEN -1
ELSE HOUR
END
Upvotes: 1