Question : Add a zero in my query since it is part of a union

I have 9 query into cursors, sometimes there will be counts for one of them. I need to somehow atleast have it return a 0 (zero) so that column will still exist in my UNION output.

Right now if there is no count it will not show on the output.

so 7 out of 9 have counts I need 8 and 9 to be zeros so the columns still display in my final results...

Answer : Add a zero in my query since it is part of a union

You should be having a table with the list of groups, otherwise create a cursor with columns Emname and Irsrc and populate it with all the records you need. Then join that group table with the summary cursor

SELECT CUNION.Emname, CUNION.Irsrc, SUM(CUNION.Cnt_irsrc) as Totals;
    FROM 'CUNION.DBF' CUNION;
    GROUP BY CUNION.Emname, CUNION.Irsrc;
    ORDER BY CUNION.Emname, CUNION.Irsrc;
    INTO CURSOR SummaryCursor

SELECT MyGroupTable.EmName, MyGroupTable.Irsrc,NVL(SummaryCursor.Totals,0) as Totals ;
   from MyGroupTable ;
   LEFT JOIN SummaryCursor ON MyGroupTable.EmName=SummaryCursor.EmName and MyGroupTable.Irsrc=SummaryCursor.Irsrc;
   INTO CURSOR SummaryCursor1
Random Solutions  
 
programming4us programming4us