Loading exercise…
Loading exercise…
Exercises are built for a keyboard. Read the task here, then open this page on a laptop to solve it.
Grand total with OVER (). An empty window, OVER (), covers every row of the result. After a GROUP BY, SUM(SUM(x)) OVER () adds up the group totals, so you can divide each group by the grand total in the same query. The inner SUM works per group; the outer one runs across all groups.
select segment, count(*) as customers, round(100.0 * count(*) / sum(count(*)) over (), 2) as pct_of_customers from customers group by segment
Elena Petrova wants a one-glance view of how 2025 completed revenue splits across the four categories.
Return category, revenue (completed, 2 decimals) and pct_of_total (the category's share of all completed revenue, in percent, 2 decimals).
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe