SQL Challenges · THE CHRISTMAS HEIST!

Weather Forensics at Scale

Difficulty: hard

Detective Quacker receives meteorological surveillance data. The weight exceeds what one duck could carry... but why would someone risk so much? He opens an email. The investigation deepens! Weve obtained high-frequency weather monitoring data—reports every 5 minutes from all districts throughout December. Thats a lot of weather snapshots! Now match Coach Waddles GPS pings to the nearest prior weather report in each location. Youll need to process millions of records to find which GPS coordinat…

Your task

Find the highest wind speed (in km/h) that Coach Waddles (duck_id = 1) drove through during any delivery. Match each GPS ping to the most recent weather report at or before that timestamp using ASOF JOIN. Weather reports are recorded per district, so you'll need to determine the district for each GPS event. You will be working with `dbquacks_xmas.gps_tracking_events` (MotherDuck), `dbquacks_xmas.weather_reports` (MotherDuck), `deliveries_log` (local), and `duck_households` (local) tables.

Tables

deliveries_log (10000 rows)

columntype
delivery_idINTEGER
household_idINTEGER
delivered_byINTEGER
delivery_timeTIMESTAMP
successBOOLEAN
parent_delivery_idINTEGER
delivery_metadataJSON

duck_households (200 rows)

columntype
household_idINTEGER
addressVARCHAR
districtVARCHAR
latitudeDOUBLE
longitudeDOUBLE
household_sizeINTEGER
income_levelVARCHAR
reported_missingBOOLEAN

dbquacks_xmas.gps_tracking_events

A table in a MotherDuck share; its columns are not listed here.

dbquacks_xmas.weather_reports

A table in a MotherDuck share; its columns are not listed here.

Database: https://dbquacks.com/data/databases/christmas_local.duckdb

This page as markdown: https://dbquacks.com/challenges/christmas/8.md

Play this challenge →