不知道你是什么数据库,我就用一个通用的方法
你自己把12个月加完
ORDER BY
CASE WHEN month = '1月' THEN 1
WHEN month = '2月' THEN 2
WHEN month = '3月' THEN 3
--继续添加其他月份的排序规则
ELSE 99
END
-------------------或者是你有一个月份维度表里面有两列字段一列是月份没有汉字,一列是有汉字的。你用没有汉字的月份去关联后,展示有月的字段,排序用没有月的数字排序------------
比如像oracel中db2或者sql server中类似可以这样
with a as (
select '1月' month_code,1 as month_number
union all
select '2月',2
union all
select '3月',3
union all
select '4月',4
union all
select '5月',5
union all
select '6月',6
union all
select '7月',7
union all
select '8月',8
union all
select '9月',9
union all
select '10月',10
union all
select '11月',11
union all
select '12月',12
)
select a.month_code,b.* from a
left join (SELECT
month_code,/*业务月份*/
amount
from 订单表 ) b on a.month_code=b.month_code
order by a.month_number/*排序用的*/
-----还有一个办法是你数据集里面不用月份这个字段,只返回月的数字,展示图表的时候用用公式形态展示------
