Search code examples
sqlreportingres

More than one SELECT in ingres report writer


Background
Im trying to create a report via ingres where i provide 2 dates ($begin_date and $end_date)
this report will provide me with errors from a system that occured between the two dates.
If these dates are less than one day apart, I should have a more detailed report.

Question
Is there any way to have more than one select in this report dependent on the difference between the dates?
like:

$end_date - $begin_date = difference
.QUERY

if difference < 1 day
    select col1, col2, count(*) as number from table
    group by col1, col2
else
    select col1, count(*) as number from table
    group by col1

Or instead have a if statement inside the SELECT, im not an experienced sql user so not sure about that last one, if its even possible.

Any help would be awesome, or any pointers what I should search for.


Solution

  • Create a proc, and use $begin_date & @end_date parameters.

    Add your logic in proc, and output is dynamic table structure.

    You should allow the object to automatically adapt to the structure in the program.