December 20, 2026 · Advent of Postgres
20. Seven reindeer Solved
MediumEXISTSsemi-join
Each reindeer can pull max_load_kg. Only reindeer that are still flying can pull anything on Christmas Eve.
Your task
Add up the max_load_kg of every reindeer that has flown on or after 2026-11-26. Return one row: capacity_kg.
Your answer returns 1 row with the columns capacity_kg.
What happens next
There it is. The recorded list fits under seven reindeer's capacity, barely. The true list doesn't. Grizzle found out about Comet, panicked, and quietly made thirty children "naughty" so the sleigh would still fly. Wrong, but not wicked. Grizzle confesses in tears over a cold cocoa. Now Christmas needs a real plan.
Solve today's puzzle to read what happens next.
The data
The North Pole's tables, a snapshot taken on December 1, 2026. Times are North Pole time (UTC). PostgreSQL runs in your browser: use Explore data to browse it.
elvesid, name, department, hired_on DATE, manager_id (→ elves.id, NULL for the Head Elf)elf_leaveelf_id, from_date DATE, to_date DATE (both days included)childrenid, name, country, city, utc_offset DOUBLE PRECISION, agewisheschild_id, toy_id, rank (1 = top wish)toysid, name, category, build_minutes, weight_gnice_list_logid, child_id, logged_at TIMESTAMP, points, reason, recorded_by (→ elves.id), terminal (→ terminals.id)terminalsid, location, departmentreindeerid, name, max_load_kgflightsid, reindeer_id, flown_on DATE, km, carrotsbuildsid, toy_id, elf_id, built_at TIMESTAMP, minutes, passed_qc BOOLEANcookie_batchesid, baked_at TIMESTAMP, elf_id, cookiesdoor_swipesid, elf_id, swiped_at TIMESTAMP, door, direction ('in' or 'out')
Hints
WHERE EXISTS (SELECT 1 FROM flights f WHERE f.reindeer_id = r.id AND …).Solution
SELECT sum(r.max_load_kg) AS capacity_kg
FROM reindeer r
WHERE EXISTS (SELECT 1 FROM flights f WHERE f.reindeer_id = r.id AND f.flown_on >= DATE '2026-11-26');
Free to play. Please don't republish the puzzles or solutions. See the Playground License Terms. Today's puzzle is also on Advent of SQL, Advent of DuckDB, Advent of MongoDB.