Interview practice question
Top three products per category
Data Engineering · SQL · Intermediate
Find the top 3 selling products in each category.
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Aggregate sales per category and product.
- Rank within each category using DENSE_RANK or ROW_NUMBER.
- Filter rank <= 3 with QUALIFY or a subquery.
- Choose the function based on how ties should behave.
- Classic top-N-per-group pattern.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.