SQL直接开窗就可以完成,无需循环:
select year_month
,sum(cnt) over(order by year_month) as concat_cnt
from (
select date_format(date,'yyyy-MM') as year_month
,count(id) as cnt
from DATE_TIME t
group by date_format(date,'yyyy-MM')
) n
当然如果要用kettle循环实现的话,大概思路如下:1、设定开始参数、结束参数
2、检测开始参数<=结束参数,ture下一步,false结束
3、执行SQL:insert into 目标表 select 年月,count(*) form 表 where date <= 开始参数
4、开始参数+1个月
重新指向2步骤,实现循环