SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Products Driving 80% of Revenue

Unsolved

Amazon merchandising applies the Pareto principle: which top products generate the first 80% of revenue? Rank products by `revenue` descending (ties broken by `product_id` ascending) and accumulate revenue down the ranking. A product belongs to the core set if the cumulative revenue of all products ranked strictly above it is less than 80% of total revenue; equivalently, the core set is the smallest set of top products whose cumulative revenue reaches at least 80%. Return `product_name`, `revenue` and `cumulative_pct` (cumulative revenue including this product as a percentage of total revenue, rounded to 2 decimals) for the core set. Order the results by `revenue` descending, then `product_id` ascending.

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:
🏢 Walmart🏢 Amazon🏢 Instacart

Submission History

Your recent query executions and answer checks

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