关于加入的问题。
我有这个查询,我从三个表加入东西。
我的问题是我得到了结果集 模型A出现两次,我只期待模型A的一行。
我想只显示18次哔哔声的模特A.但是也希望向模型B显示0声嘟嘟声。
我该怎么做?我没有正确地进行连接吗?..
查询:
SELECT DISTINCT
TO_CHAR(C.KR_DATE,'YYYY/MM/DD') AS K_Date,
A.OUT_FIELD1 AS MODEL_NBR,
A.IN_FIELD1 AS LOCATIONS,
sum(schemaJoe.FUNC_GET_LINE_TOUCHES(C.ORG, B.DELIV_ID, B.DELIV_DTL_NUM)) AS BEEPS
FROM
schemaJoe.TABLE_A A, schemaJoe.TABLE_B B, schemaJoe.TABLE_C C
WHERE A.ORG = 'JOE'
AND A.REF_TYPE = 'JOES_MODEL'
AND A.ORG = B.ORG (+)
AND A.OUT_FIELD1 = B.PART_NBR (+)
AND B.DELIVERY_ID = C.DELIVERY_ID (+)
AND C.CALC_REQUEST_DATE (+) BETWEEN TO_DATE('7/30/2016', 'MM/DD/YYYY') AND TO_DATE('8/30/2016', 'MM/DD/YYYY')
AND B.LINE_STATUS (+) IN ( 'CREATED','OPEN','PROECSSING')
GROUP BY
C.KR_DATE,
A.OUT_FIELD1,
A.IN_FIELD1,
C.ORG,
B.DELIVERY_ID,
B.DELIV_LANE
ORDER BY
K_Date ASC,BEEPS DESC,MODEL_NBR ASC,LOCATIONS ASC
结果: