Advanced
Open
Pro
Cumulative Revenue Share: Which Products Make Up 80% of Revenue
Given per-product revenue:
product_revenue
product_id | revenue
-----------+--------
P1 | 40000
P2 | 25000
P3 | 15000
P4 | 10000
P5 | 6000
P6 | 4000
Identify the minimal set of top-selling products whose combined revenue reaches 80% of total revenue (a Pareto/80-20 analysis) — return each qualifying product along with its individual revenue share and its running cumulative share, ordered from highest revenue to lowest.
Write the full query, and explain why an ordinary GROUP BY with a
HAVING clause cannot express "cumulative running share crosses a
threshold," and what tool actually can.
Share this question