sqlserver为例,创建表
create table t
(月份 int,
注册用户数 int)
insert into t values (1,111);
insert into t values (2,122);
insert into t values (3,133);
insert into t values (4,144);
执行:
select t1.月份,SUM(t2.注册用户数) 注册用户数 from t t1 left join t t2 on t1.月份>=t2.月份
group by t1.月份
结果: