Previous question: https://dba.stackexchange.com/q/296218
I almost got this working.
The problem that I have is that this variant of query does not merge the line from the SELECT with the one in the UNION if they are the same:
SELECT CODPRO, VALPRO, COALESCE(SUM(UVCLIV), 0) AS SUM
FROM FGE50LM0TV.GESUPD
WHERE CNFLIG = '2'
AND CODPRO IN (SELECT VALINV FROM FGE50LM0TV.SVINVD WHERE NUMINV = 59)
GROUP BY CODACT, CODPRO, VALPRO
UNION (SELECT VALINV, 0, 0 FROM FGE50LM0TV.SVINVD WHERE NUMINV = 59) ;
This is what SVINVD looks like:
This is what GESUPD looks like:
No line for "PRODUIT5" here.
So in consequence I get a doubled line:



Asked by Oliviu Vais
(33 rep)
Jul 28, 2021, 07:26 AM
Last activity: Feb 6, 2022, 07:36 PM
Last activity: Feb 6, 2022, 07:36 PM