Skip to content
Advertisement

Find the record which have the greater value in top 2 month

I want to retrieve a record where the age group is greater than 50 and show the top 2 month.

As we can see in the age_group there is 2 row fall in month ‘3’. The total value in month ‘3’ is 28. And the another month which have the greater value is month ‘4’

Advertisement

Answer

You must group by month and sum the infections before you sort and return the top2:

See the demo.
Results:

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