help
有个数据库表结构纪录了每月的销售额
month money
1 10
2 20
3 30
4 20
增加一列 计算到该月为止的销售总额
month money sum
1 10 10
2 20 20+10
3 30 30+20+10
4 20 20+30+20+10
SQL语句如何写???
问题点数:0、回复次数:2Top
1 楼xluzhong(Ralph)回复于 2005-04-03 19:58:23 得分 0
select month,money,
sum=(select sum(money) from tablename where month<=a.month)
from tablename aTop
2 楼yhever(yh)回复于 2005-04-03 20:05:27 得分 0
如果里面有年度的话
是不是加个
select year,month,money,
sum(select sum(money) from tablename where month<=a.month and year = a.year)
from tablename aTop




