Skip to content
Advertisement

Trying to loop a query to get monthly counts

I need to get the number of employees who had active coverage for each package, per month. Looking at a span of 50 months, so don’t want to run it 50 times. I need the number of people with each package on the last day of each month between these dates

I’m sure I can write a loop to check for each date, but can’t for the life of me figure it out.

Advertisement

Answer

You could use the connect by syntax to generate a series of last days in each month for the appropriate range, and then join that on a count distinct employee numbers:

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