17.有一个表结构如下
EmpID DeptID Price001 A 500
002 A 600
003 C 400
004 B 550
005 A 700
006 C 300
查出如下结果,请写出SQL语句
empid deptid price
---------- ---------- ----------- -----------
001 A 500 500
002 A 600 1100
005 A 700 1800
004 B 550 550
003 C 400 400
006 C 300 700谢谢各位哥哥姐姐!
EmpID DeptID Price001 A 500
002 A 600
003 C 400
004 B 550
005 A 700
006 C 300
查出如下结果,请写出SQL语句
empid deptid price
---------- ---------- ----------- -----------
001 A 500 500
002 A 600 1100
005 A 700 1800
004 B 550 550
003 C 400 400
006 C 300 700谢谢各位哥哥姐姐!
DeptID,
price=(select sum(price) from tb where deptid =a.deptid and id<=a.id)
from tb a
DeptID,
price=(select sum(price) from tb where deptid =a.deptid and empid<=a.empid)
from tb a order by deptid
select sum(price) from tb where deptid=a.deptid and empid<=a.empid ) from tb a
order by deptid,empid