标签:
例题:查找出型号表的所有型号,该型号共领料,和入库的个数
1 SELECT
2 A.型号,
3 NVL(B.领用个数SUM,0) AS 共领料,
4 NVL(C.入库数量SUM,0) AS 共入库,
5 FROM 型号表 A
6 LEFT JOIN (
7 SELECT SUBB.型号,SUM(SUBB.领用个数) AS 领用个数SUM
8 FROM 领料表 SUBB
9 GROUP BY 型号
10 ) B
11 ON B.型号 = A.型号
12 LEFT JOIN (
13 SELECT SUBC.型号,SUM(SUBC.入库数量) AS 入库数量SUM
14 FROM 入库表 SUBC
15 GROUP BY 型号
16 ) C
17 ON C.型号 = A.型号
http://q.cnblogs.com/q/40107/
标签:
原文地址:http://www.cnblogs.com/Ly426/p/5300830.html