1.数据表结构
2.目标效果(以type值作为分组条件,分组累加)
3.sql语句
SELECT id, type, money, (SELECT SUM(money) FROM cum_demo WHERE type = A.type AND id <= A.Id) totalMin FROM cum_demo A ORDER BY A.type,A.id;