I have his query that works fine, but I need it to return a line when nothing is found to suit the conditions:
SELECT D.CODPRO, D.VALPRO, COALESCE(SUM(d.UVCLIV), 0) AS SUM
FROM FGE50LM0TV.GESUPE E LEFT JOIN FGE50LM0TV.GESUPD D
ON E.NUMSUP=D.NUMSUP AND E.SNUSUP=D.SNUSUP
WHERE E.CODACT = '001'
AND D.CODPRO ''
AND E.CIRPIC = 'HUB'
AND E.ETASUP IN ('30','40','60')
AND D.CNFLIG = '2'
AND E.TOPMNQ '1'
AND D.CODPRO IN ('TST UOP 1')
GROUP BY D.CODACT, D.CODPRO, D.VALPRO
Maybe the question is not that clear.
Let me simplify it:
I want the following query to return the CODPRO, VALPRO, 0 as SUM of UVCLIV when CNFLIG is of '2':
SELECT CODPRO, VALPRO, COALESCE(SUM(UVCLIV), 0) AS SUM
FROM FGE50LM0TV.GESUPD
WHERE CNFLIG = '2'
AND CODPRO IN ('TST UOP 1')
GROUP BY CODACT, CODPRO, VALPRO ;
This is what I have for this product now in the table:
I use this query to insert a line of PRODUCT, VARIANT, QUANTITY into a file (H) by making a sum of all lines with that PRODUCT/VARIANT from another file (D). I have all those conditions that I wrote, and I want to receive a line with the PRODUCT, VARIANT, 0 as SUM for the situation when the SQL does not find anything according to my conditions.
I am not using MySQL workbench. I am on an IBM Emulator Utility v 14.14

Asked by Oliviu Vais
(33 rep)
Jul 27, 2021, 07:12 AM
Last activity: Jul 28, 2021, 07:58 AM
Last activity: Jul 28, 2021, 07:58 AM