我运行了以下查询,返回36行数据
SELECT A.OBJECTIVE, SUM(A.T_VALUE) FROM DB2ADM2.TFINTR10 A WHERE (A."YEAR" =10) AND (A.OBJECTIVE BETWEEN 'WAAAA' AND 'WZZZZ') GROUP BY A.OBJECTIVE When I merge with another table and add the Narration field (OB_Narr5) the rows of data are reduced as the Ob_Narr5 does not exist for every Objective, see sql. SELECT A.OBJECTIVE, SUM ( A.T_VALUE ), B.OB_NARR5 FROM DB2ADM2.TFINTR10 A INNER JOIN DB2ADM2.TFINOBJP B ON B.OB_12345 = A. OBJECTIVE WHERE (A."YEAR" =10) AND A.OBJECTIVE BETWEEN 'WAAAA' AND 'WZZZZ' GROUP BY A.OBJECTIVE, B.OB_NARR5 The rows returned are now only 4. How can I return all the rows including the blank fields and / or return just the rows with the blank fields?
感谢回复,Left和Full Outer Join都有效.
How do I replace thewith a blank instead please? WAAAA -173597.12 WABAA 222717.76 GENERAL
小智.. 5
使用LEFT JOIN
而不是INNER JOIN
删除包含空列的左表的条目
使用LEFT JOIN
而不是INNER JOIN
删除包含空列的左表的条目