id name money
1 aaa 1000
2 bbb 2000
4 ccc 3000
6 ddd 5000
9 eee 10000
请你写一条sql语句,执行的结果是:
id name money
1 aaa 1000
2 bbb 3000
4 ccc 6000
6 ddd 11000
9 eee 21000
------解决方案--------------------
- SQL code
select id, name, (select sum(money) from t a where a.id <= t.id) as money from t