December 24, 2026 · Advent of SQL
24. Santa's message Solved
Hardstring_agg ORDER BYJOIN
Christmas Eve. The sleigh is packed for two trips, the reindeer are stamping, and Santa himself comes down to the data room for the first time. "The thirty children who were wronged," he says. "Each gets an apology note. Their top wishes are hiding a message for you."
Your task
Take the fake entries (night entries on LOGI-07) in the order they were made. For each one, take the first letter of that child's top wish (rank 1, the first toy on their list), and join the letters into one string. Return one row with message.
Your answer returns 1 row with the columns message.
What happens next
You read it out loud, and the whole workshop cheers. Santa shakes your hand. "Best data elf we've ever had. Well, the only one. But still the best." Bring that message to the finale to claim your prize.
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). DuckDB 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, 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
string_agg(left(t.name, 1), '' ORDER BY l.logged_at) builds the string in order.Solution
SELECT string_agg(left(t.name, 1), '' ORDER BY l.logged_at) AS message
FROM nice_list_log l
JOIN wishes w ON w.child_id = l.child_id AND w.rank = 1
JOIN toys t ON t.id = w.toy_id
WHERE l.terminal = 'LOGI-07' AND hour(l.logged_at) < 5;
Free to play. Please don't republish the puzzles or solutions. See the Playground License Terms. Also on Advent of MongoDB.