Explainable business reporting · Original fictional data · Free files and full answers
Select the minimal ranked prefix covering eighty percent of revenue
For period2 rank SKUs by gross revenue descending, ties sku. Include rows while prior cumulative revenue<80% of total, including the row crossing80%. Return sku,revenue_cents,cumulative_cents sorted rank.
Use this fixed business case to build a checked CSV and a replayable SQL handoff. No account required. Scenario datasets are shared across related exercises; each exercise has its own decision and output contract.
Your output contract
- For period2 rank SKUs by gross revenue descending, ties sku. Include rows while prior cumulative revenue<80% of total, including the row crossing80%. Return sku,revenue_cents,cumulative_cents sorted rank.
- Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
- These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.
Return columns exactly as sku, revenue_cents, cumulative_cents. Sort order follows the task. Output has 3 rows; an empty CSV field means NULL.
Source data
sales
7 source rows · Download sales CSV
| id INTEGER | sku TEXT | channel TEXT | period INTEGER | qty INTEGER | price INTEGER | cost INTEGER | returned INTEGER |
|---|---|---|---|---|---|---|---|
| 1 | A | search | 1 | 10 | 100 | 60 | 1 |
| 2 | B | 1 | 5 | 200 | 150 | 0 | |
| 3 | C | social | 1 | 4 | 300 | 200 | 1 |
| 4 | A | search | 2 | 12 | 120 | 65 | 2 |
| 5 | B | 2 | 4 | 190 | 150 | 1 | |
| 6 | C | search | 2 | 6 | 280 | 210 | 0 |
| 7 | D | social | 2 | 3 | 500 | 450 | 0 |
touches
6 source rows · Download touches CSV
| customer TEXT | minute INTEGER | channel TEXT |
|---|---|---|
| U1 | 0 | search |
| U1 | 0 | |
| U1 | 5 | social |
| U2 | 1 | social |
| U2 | 3 | search |
| U3 | 2 |
funnel
10 source rows · Download funnel CSV
| user TEXT | minute INTEGER | step TEXT |
|---|---|---|
| U1 | 0 | visit |
| U1 | 2 | cart |
| U1 | 5 | buy |
| U2 | 0 | buy |
| U2 | 2 | visit |
| U2 | 4 | cart |
| U3 | 1 | visit |
| U3 | 1 | buy |
| U4 | 1 | visit |
| U4 | 2 | cart |
Field dictionary and schema
sales: id INTEGER — Stable source record identifier; not a row position. sku TEXT — Literal business key or category label. Match exactly and retain NULL where present. channel TEXT — Literal business key or category label. Match exactly and retain NULL where present. period INTEGER — Reporting period label1 or2, not an elapsed-time measurement. qty INTEGER — Physical quantity; multiply through assembly paths when the task requires it. price INTEGER — Selling price in integer cents per physical unit. cost INTEGER — Acquisition cost in integer cents per physical unit. returned INTEGER — Number of physically returned units. touches: customer TEXT — Literal business key or category label. Match exactly and retain NULL where present. minute INTEGER — Elapsed UTC minute from the fictional scenario origin. channel TEXT — Literal business key or category label. Match exactly and retain NULL where present. funnel: user TEXT — Literal business key or category label. Match exactly and retain NULL where present. minute INTEGER — Elapsed UTC minute from the fictional scenario origin. step TEXT — Literal business key or category label. Match exactly and retain NULL where present.
A method you can reuse
- For period2 rank SKUs by gross revenue descending, ties sku. Include rows while prior cumulative revenue<80% of total, including the row crossing80%. Return sku,revenue_cents,cumulative_cents sorted rank.
- For the first output record, sku = C; revenue_cents = 1680; cumulative_cents = 1680.
- Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.
Watch for this wrong turn
Filtering cumulative<=80% drops the very contributor needed to reach the coverage target.
Run and check in SQLite
Your SQL runs locally in the existing SQLite worker. The checker compares every column, row, type, value and row order with this fixed output. It accepts equivalent SELECT or WITH queries. Browser storage keeps your SQL on this device when available.
Complete worked SQL and expected output
WITH x AS (SELECT sku,SUM(qty*price) revenue FROM sales WHERE period=2 GROUP BY sku), r AS (SELECT *,SUM(revenue) OVER(ORDER BY revenue DESC,sku ROWS UNBOUNDED PRECEDING) cumulative,SUM(revenue) OVER() total FROM x) SELECT sku,revenue revenue_cents,cumulative cumulative_cents FROM r WHERE cumulative-revenue<0.8*total ORDER BY revenue DESC,sku;
"sku","revenue_cents","cumulative_cents" "C","1680","1680" "D","1500","3180" "A","1440","4620"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects