SQL ORDER BY months starting with this month

前端 未结 6 1682
逝去的感伤
逝去的感伤 2021-01-24 21:23

I have a query that returns months 1-12. (INT)

Is there a way to order the results starting on this month desc?

Example

3
4
5
6
7
8
9
10
11
12
1         


        
6条回答
  •  灰色年华
    2021-01-24 22:00

    Similar to Brad's answer, add a year column, then

    ...
    ORDER BY year, month 
    

    Use ASCending or DESCending sort modifiers depending on exactly what you want to do.

提交回复
热议问题