题目
有如下三张表T0222A(仓库期初)
T0222B(仓库发出)
T0222C(仓库收入)
要求得到如下结果:
该如何写这个SQL?
测试语句
CREATE TABLE T0222A
(WAREHOUSE VARCHAR(10),
ITEM VARCHAR(10),
QTY INT)
INSERT INTO T0222A VALUES ('A','P001',100);
INSERT INTO T0222A VALUES ('A','P002',200);
INSERT INTO T0222A VALUES ('B','P001',120 );
CREATE TABLE T0222B
(WAREHOUSE VARCHAR(10),
ITEM VARCHAR(10),
QTY INT
)
INSERT INTO T0222B VALUES ('A','P001',50);
INSERT INTO T0222B VALUES ('B','P001',30);
CREATE TABLE T0222C
(WAREHOUSE VARCHAR(10),
ITEM VARCHAR(10),
QTY INT
)
INSERT INTO T0222C VALUES ('A','P001',10);
INSERT INTO T0222C VALUES ('A','P002',20);
INSERT INTO T0222C VALUES ('C','P001',15);
INSERT INTO T0222C VALUES ('C','P003',10);
参考答案
应读者的要求,我将参考答案公布了,有需要的同学可以在下方公众号「数据前线」(非本号)后台回复关键字:0222,即可获取。还是建议先独立答题~
数据前线
后台回复关键字:1024,获取一份精心整理的技术干货