SQL Detective

Solve a yard mystery with SQL: ten levels of queries against a small database, in as few characters as you can.

Level 1 of 10

The guest list

The golden rubber duck is gone from its pedestal in the duck-pond room. Start with the crew: everyone who works in the yard, with every column the people table holds.

The answer has these columns, in this order: id, name, role, hired_on, nest

The database

people
  • id the crew number
  • name full name
  • role job
  • hired_on first day, YYYY-MM-DD
  • nest which building they sleep in; empty for off-site
badges
  • id the badge number
  • person_id whose badge it is
  • code the code printed on it
  • issued_on handed out on, YYYY-MM-DD
  • active 1 = still opens doors, 0 = reported lost
door_log
  • id the swipe number
  • day which day, YYYY-MM-DD
  • at what time, HH:MM
  • door which door opened
  • person_id whose badge was used
cafe_orders
  • id the order number
  • day which day, YYYY-MM-DD
  • at what time, HH:MM
  • person_id who ordered
  • item what they had
  • price what it cost, in pounds
messages
  • id the message number
  • sent_on which day, YYYY-MM-DD
  • sent_at what time, HH:MM
  • sender_id who wrote it
  • recipient_id who it went to
  • body what it said

Write a query, then press Run query.

More in the yard