0
Basically the logic should be the following. Return the Acs (aircraft) that has the component RCF6709 installed (case 1) or not installed (case 0). See:
Retrieve active aircraft on
AC_Master
;Whereas there should be 1
pn
RCF6709 by aircraft, I made the case to tell1
(OK) or0
(Is not installed);I believe the error is on the line I put
WHERE A.PN IN ('RCF6709')
, because today the query is returning everything that is installed (case 1). But when I extract the Bruno report, I identify that there are 5 Acs (aircraft) that do not have thispn
installed.
SELECT B.AC,
A.PN,
COUNT (DISTINCT (A.AC)) AS "Nº OF CONTROLS",
B.AC_TYPE ||'-'|| B.AC_SERIES AS "TYPE/SERIES",
(CASE WHEN COUNT (DISTINCT (A.AC)) = 1 THEN 1 ELSE 0 END) AS "CHECK"
FROM ODB.PLANNING A
LEFT JOIN ODB.AC_MASTER B
ON A.AC = B.AC
WHERE A.PN IN ('RCF6709')
AND B.AC_TYPE ||'-'|| B.AC_SERIES = 'ATR72-600'
AND B.STATUS = 'ACTIVE'
GROUP BY B.AC,
B.AC_TYPE ||'-'|| B.AC_SERIES,
A.PN
Without knowing the structure complicates but I think you should reverse your order of joins FROM ODB.AC_MASTER B LEFT JOIN ODB.PLANNING
– Motta