码迷,mamicode.com
首页 > 其他好文 > 详细

多表联查

时间:2015-10-06 16:48:29      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:

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.型号
18 ORDER BY A.型号 ASC

多表联查

标签:

原文地址:http://www.cnblogs.com/ckaifeng/p/4857272.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!