Skip to content
Advertisement

Is there a way to have a placeholder when select returns no rows?

I have a table, report_total, that contains calculated values for some of the total_types_cd (codes) but not necessarily all of them.

If there is no corresponding row, I’d like to have a placeholder in the select such that the renamed total_amt (unitem_cntrib/total_contrib…) has a value of 0 and I always get a return of 8 items even if no values were found. I thought maybe the COALESCE function might work but I have not been able to write a query that was acceptable.

These query results are going into a pdf report and so I want something, even if it is 0. Right now, no report is getting generated because the select returns no row if all the values are not present. Below is my select statement and the $P{ReportID} is input into the report generator.

Advertisement

Answer

I think you want conditional aggregation:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement