枚举顺序

问题描述:

我只想使用枚举值{9月,10月,11月,12月}订购查询输出
所以我写

从每月{9月,10月,11月,12月}的费用顺序中选择*

因为它将简单地按字母顺序显示记录,即从4月开始显示,但是由于我们的日历从9月开始显示,因此我希望它是显示的第一个记录.谁能帮我?谢谢!

i just want to order the query out put using enumeration value {september, october, november, december}
so i write

select * from fee order by month {september, october, november, december}

since it will simply dispaly the record in alphabetic order i.e. starting from April, but since our calender begins from September i want it to be the first record to be displayed. can anyone help me? Thanks!

我不确定您要实现的目标,但是您尝试将月份转换成整数并按此排序. br/>
否则,您可以创建一个表变量,其中月份和第二列表示顺序.将其连接到您的数据,然后按临时表的排序列进行排序.

I''m not sure what you''re trying to achieve, but you try converting the months into integers and sorting on it like that.

Otherwise, you could create a table variable with the months and a second column indicating order. Join that up to your data and then order by the temporary tables order column.

Either should do it.


我不确定要订购的订单,但可以根据月份进行自定义订购.您可以执行以下操作:
I''m not exactly sure the order you are going for, but you can do a custom ordering based on the month. You could do something like this:
SELECT
    *
FROM Fee
ORDER BY
    CASE Month
        WHEN 'September' THEN 1
        WHEN 'April' THEN 2
        -- ...
        ELSE 999
    END AS MonthOrder ASC


不确定语法是否完全正确,但是您会明白的.


Not sure if the syntax is exactly correct, but you get the idea.