SQL Challenges · WEEKLY QUACK CHALLENGE!
STANDING ROOM ONLY
Difficulty: hard
Safety Warden Bufflehead marches in wearing a hi-vis vest, clipboard trembling. The Feather Fairs fire code allows five ducks inside any attraction at a time, Duckbert. FIVE. And I have a stack of complaints saying somebody broke it on Saturday. The Tilt-a-Waddle crew swear theyre innocent — we had the most riders, sure, but they were in and out in six minutes! The bumper boat crew say their sessions run long but never crowded. I dont care who had the most riders or the longest rides. I want th…
Your task
Each visit is one duck, inside the attraction from its entry time up to, but not including, its exit time — a duck leaving at 14:45 is already outside at 14:45. For each attraction, find the largest number of ducks inside at the same moment. Return the name of the attraction with the highest peak; on a tie, the alphabetically first. You will be working with the `visits` and `attractions` tables.
Tables
visits (34 rows)
| column | type |
|---|---|
visit_id | INTEGER |
attraction_id | INTEGER |
entered_at | TIMESTAMP |
left_at | TIMESTAMP |
attractions (4 rows)
| column | type |
|---|---|
attraction_id | INTEGER |
name | VARCHAR |
Database: https://dbquacks.com/data/databases/weekly_202638_12_feather_fair.duckdb
This page as markdown: https://dbquacks.com/challenges/weekly/12.md