Skip to content
Advertisement

Oracle SQL – Count, per month, how many times a site appears in the results

I’m not sure if I will explain this correctly so apologies in advance.

I’m looking to put together a report that shows the number of times a site (central_site.site_code & central_site.site_name) appears in a report and then total this up for each month with a grand total at the end. The date to summarize into month values is job.actual_start_date

What I’m looking for is something like:

The code I have got so far to produce all the information that I would like summarizing in the format above is:

I just don’t know the syntax / formulas to be able to total each site up per month and then provide a total for the year.

Advertisement

Answer

I think you want conditional aggregation:

This is assuming that “number of times” is simply a count. Your question doesn’t specify *what column is used to specify the date. So, that element needs to be filled in.

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