Statistical reporting contracts · Original fictional data · Free files and full answers
Report means after trimming one extreme on each side
Within each team remove exactly one smallest and one largest known observation, ties by id. Average remaining values rounded to two decimals. Return team,trimmed_mean sorted team.
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
- Within each team remove exactly one smallest and one largest known observation, ties by id. Average remaining values rounded to two decimals. Return team,trimmed_mean sorted team.
- Return exactly the declared columns and order. Money uses integer cents; all time values are elapsed UTC minutes unless a field is explicitly a day index. NULL is unknown and differs from numeric zero.
- These are original fictional records and exercise policies. All source tables in this case are included in the downloadable pack.
Return columns exactly as team, trimmed_mean. Sort order follows the task. Output has 3 rows; an empty CSV field means NULL.
Source data
observations
16 source rows · Download observations CSV
| id INTEGER | team TEXT | day INTEGER | value INTEGER | weight INTEGER |
|---|---|---|---|---|
| 1 | A | 1 | 10 | 1 |
| 2 | A | 2 | 20 | 2 |
| 3 | A | 3 | NULL | 1 |
| 4 | A | 4 | 40 | 1 |
| 5 | A | 5 | 100 | 1 |
| 6 | A | 6 | 20 | 3 |
| 7 | B | 1 | 5 | 2 |
| 8 | B | 2 | 5 | 1 |
| 9 | B | 3 | 15 | 1 |
| 10 | B | 4 | 25 | 2 |
| 11 | B | 5 | 35 | 1 |
| 12 | B | 6 | 55 | 1 |
| 13 | C | 1 | 0 | 1 |
| 14 | C | 2 | 10 | 1 |
| 15 | C | 3 | 30 | 2 |
| 16 | C | 4 | 10 | 1 |
Field dictionary and schema
observations: id INTEGER — Stable record or business key; retain its declared type. team TEXT — Literal text label or key; comparisons use SQLite binary text semantics. day INTEGER — Exact integer measurement; use the task rule for units and ordering. value INTEGER — Exact integer measurement; use the task rule for units and ordering. weight INTEGER — Exact integer measurement; use the task rule for units and ordering.
A method you can reuse
- Within each team remove exactly one smallest and one largest known observation, ties by id. Average remaining values rounded to two decimals. Return team,trimmed_mean sorted team.
- Inspect the source grain, keys and ties before writing the query. Use the worked SQL and complete expected CSV to review any mismatch.
Watch for this wrong turn
Removing every tied minimum/maximum trims a variable number of observations.
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 r AS (SELECT *,ROW_NUMBER() OVER(PARTITION BY team ORDER BY value,id) n,COUNT(*) OVER(PARTITION BY team) total FROM observations WHERE value IS NOT NULL) SELECT team,ROUND(AVG(value),2) trimmed_mean FROM r WHERE n>1 AND n<total GROUP BY team ORDER BY team;
"team","trimmed_mean" "A","26.67" "B","20" "C","10"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects