洗车液配方简单:SQL 数据库问题(急)
来源:百度文库 编辑:杭州交通信息网 时间:2024/09/21 09:06:47
有表 A 字段 为
ID SELL
1 2.0
2 3.0
3 3.4
4 3.5
编写一个存储过程实现以下输出
ID SELL TOTAL
1 2.0 2.0
2 3.0 5.0
3 3.4 8.4
4 3.5 11.9
-----------
各位大虾帮个忙 谢谢!~~~~~~~~~
ID SELL
1 2.0
2 3.0
3 3.4
4 3.5
编写一个存储过程实现以下输出
ID SELL TOTAL
1 2.0 2.0
2 3.0 5.0
3 3.4 8.4
4 3.5 11.9
-----------
各位大虾帮个忙 谢谢!~~~~~~~~~
不用存储过程,一条语句即可。
select id,sell,(select sum(sell) from a where id<=TableA.id) as total
from A as tableA
order by id
如果非用存储过程,请说明。