SQL ORDER BY months starting with this month

前端 未结 6 1698
逝去的感伤
逝去的感伤 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:07

    You can add a year in there for sort purposes. Make them output something like:

    2010-03
    2010-04
    ...
    2011-01
    2011-02
    

    Pseduo code:

    WHERE year >= 2010 AND month >= 3
    

    Not sure what your query is or the data backing it though.

提交回复
热议问题