Skip to content
Advertisement

Group and subquery issue

This is my sample data

I need to find the title with max rating in each genre.

Thanks for the help.

Advertisement

Answer

One option uses a subquery for filtering:

This would take advantage of an index on (genre, rating).

In MySQL 8.0, you can also use window functions:

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