Skip to content
Advertisement

How to calculate average for every month from start from year in Presto’s SQL (Athena)?

Below is an example of the table data I have

I would like to generate a result set as below

I tried to use window function OVER() and PARTITION() but I managed to get average on month by month rather than starting from the year.

Any suggestions, please.

Thanks

Advertisement

Answer

I think you want:

This puts each year in a separate partition, and the order partition rows by month.

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