Skip to content
Advertisement

Top 3 services used for each day – SQL [closed]

The query below gives me top 3 services for 6th June 2021.

I want to repeat this for each day of June.

How do I do that? I was thinking of iterating over a date range but that is not working. Is there a way to do it with some nested queries or group by?

Advertisement

Answer

You can use window functions with aggregation. Something like this:

Note: This uses standard date formats for the date constants.

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