我的观点显示:
d_date d_shop d_qty r_date r_shop r_qty 12-oct-12 ABC 20 12-oct-12 XYZ 20 12-oct-12 ABC 15 12-oct-12 XYZ 0 12-oct-12 XYZ 10 12-oct-12 ABC 10 12-oct-12 ABC 25 12-oct-12 XYZ 10 12-oct-12 XYZ 10 12-oct-12 ABC 0
我想检查receive_shop
即。正确答案是:
r_date r_shop r_qty 12-oct-12 XYZ 10
我正在使用SQL Server 2005
答案 0 :(得分:1)
我对这个问题并不十分清楚,但也许你正在寻找这样的东西:
select r_date, d_shop, sum(d_qty)-sum(r_qty)
from asdf
group by r_date, d_shop