Loading exercise…
Loading exercise…
Exercises are built for a keyboard. Read the task here, then open this page on a laptop to solve it.
Cumulative share. A cumulative share is a running total divided by the grand total. The running total is an ordered window; the grand total is an empty one, OVER (). Use a ROWS frame so tied values don't jump in together, and sort the final result the same way the running total adds up.
select segment, count(*) as customers,
round(100.0 * sum(count(*)) over (order by count(*) desc rows between unbounded preceding and current row)
/ sum(count(*)) over (), 2) as cum_pct
from customers
group by segment
order by customers descElena Petrova wants a Pareto view of the catalogue: products from best to worst seller with the running share of revenue, to see how few products make up most of the sales.
Return product_name, revenue (completed, 2 decimals) and cum_share_pct (the running total of revenue from the top product down to this one, as a percent of all completed revenue, 2 decimals), highest revenue first. On equal revenue, sort by product_name.
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe