这个需要在SQL里面处理,
或是引用单元格数据
-------------------------例子-----------------------
with aa as (
select '2023-01' as period,100 as ndata from dual
union all
select '2023-02' as period,88 as ndata from dual
union all
select '2023-03' as period,77 as ndata from dual
union all
select '2023-04' as period,85 as ndata from dual
union all
select '2023-05' as period,23 as ndata from dual
union all
select '2023-06' as period,99 as ndata from dual
)
select * from aa
union all
select 'Q1',avg(ndata) from aa where period in ('2023-01','2023-02','2023-03')
union all
select 'Q2',avg(ndata) from aa where period in ('2023-04','2023-05','2023-06')
union all
select '季度环比',(avg(case when period in ('2023-04','2023-05','2023-06') then ndata else null end)-avg(case when period in ('2023-01','2023-02','2023-03') then ndata else null end))/avg(case when period in ('2023-01','2023-02','2023-03') then ndata else null end)
from aa
结果
