将sql转化以下,直接可以随便查询任何一季度数据:
select 年,季,sum(weigth) totalweigth from (
select
substr(report_date,1,4) 年,
case when substr(report_date,5,6) between '01' and '03' then 1
when substr(report_date,5,6) between '04' and '06' then 2
when substr(report_date,5,6) between '07' and '09' then 3
when substr(report_date,5,6) between '10' and '12' then 4 end as 季,
report_date,weigth
from eva_norm_report
/**
(
select '202201' report_date, 50 weigth
union all
select '202204' report_date, 60 weigth
union all
select '202207' report_date, 70 weigth
union all
select '202209' report_date, 40 weigth
union all
select '202210' report_date, 30 weigth
union all
select '202212' report_date, 80 weigth
) s
*/
-- where substr(report_date,1,4)='2022'
) ss
where 1=1
-- and 季 = 2
-- and 年='2022'
group by 年,季