The Analyst / SQLAll lessons ↗
Day 22 · SQL mastery path

Percentages and ratios

Calculate each customer's share of total revenue.

01 · Learn

Study the pattern

Calculate each customer's share of total revenue. Predict the output before running the example.

SELECT customer_id,SUM(amount) AS revenue,ROUND(100.0*SUM(amount)/(SELECT SUM(amount) FROM orders),1) AS revenue_pct FROM orders GROUP BY customer_id ORDER BY revenue DESC;
02 · Recall

Explain it from memory

What does today's SQL feature do, and when would you use it?

03 · Practice

Run SQL in your browser

Run the example, then modify one clause and predict how the result changes.

Loading SQL engine…
04 · Repeat

Consolidate the skill