Search code examples
mysqlsortinglimit

How to get the top 10 of each group in a mysql query?


The question pretty much states the issue. I'd like to get the top N scoring items in each category, in a mysql query which is sorted first by group, then score. How to do this?


Solution

  • I believe this was answered here: Limit the number of rows per ID

    Basically you get a table that contains row numbers in each partition (category) and then select records with row <= 10.