Skip to main content
All Problems
hard0% acceptance

Top 3 Best-Selling Products Per Category

Find the top 3 best-selling products (by total quantity sold) in each category. Return category name, product name, total quantity sold, and the rank within the category. Use a CTE with a window function, then filter to rank <= 3.

Schema

🔑idINT
nameTEXT
descriptionTEXTNULL
postgresql

Run your query to see results

Press Ctrl + Enter to execute