Problems / Top N per Group / Editorial
Top-N-per-group is one of the most common window function interview questions.
ROW_NUMBER()
category
rating DESC
WHERE rank <= 3
If you wanted to include all ties at the boundary, you would use RANK() instead of ROW_NUMBER().
RANK()
Solve Top N per Group yourself →