How do you find the top-N per group (e.g., top 3 products per category by revenue) using SQL?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
Overview: Asks how to return the top N rows within each group in SQL, such as the three highest-revenue products in every category. Tests how you structure the query, how ties at the cutoff are handled, and when other query shapes perform better on large tables.