时间:2021-07-01 10:21:17 帮助过:3人阅读
--原始数据
select templateid,needitem1Count from db_tank..TS_CardMain
--累计数据
select t1.templateId,t1.needitem1Count,sum(t2.needitem1count) sum_num from db_tank..TS_CardMain t1
cross join db_tank..TS_CardMain t2
where t2.templateid <= t1.templateid
group by t1.templateid,t1.needitem1Count
T-SQL利用笛卡尔积累计、累加
标签:info rom select 分享 group 技术 count edit inf