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.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.