SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Amazon: Best-Selling Products per Category

Unsolved

Amazon Category Managers identify best-performing merchandise across catalog categories. Write a SQL query using the `DENSE_RANK()` window function to find the top-selling product in each product category by total units sold. If multiple products in the same category are tied for the highest units, return all tied products. Return `category_name`, `product_id`, `product_name`, and `total_units_sold`. Order the final output by `category_name ASC`, then `product_id ASC`. Note: Window function support requires DuckDB / full SQL engine capabilities. This question is staged for the upcoming DuckDB browser engine.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Amazon

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM products
Full source dataset
9 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine