Airbnb-style Company ChallengeBeginnerVerified answerSQLite live

Booking Log

Return booking_id, listing_id, nights, and booking_date for all bookings, ordered by booking_id.

  • Date analysis
  • Sorting

Challenge brief

Understand the request

Operations Operations needs a full booking log to cross-check reservation records against the support ticket queue.

Show all bookings with listing, nights stayed, and booking date.

Return

  • booking_id
  • listing_id
  • nights
  • booking_date

Constraints

  • Include every booking
  • Order by booking ID

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

bookings

  • booking_idINTEGER
  • listing_idINTEGER
  • nightsINTEGER
  • booking_dateDATE

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

All requested fields belong to the booking fact.

Hint 2

Keep the full booking population.

Hint 3

Use the booking key to stabilize the log.

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT booking_id, listing_id, nights, booking_date FROM bookings ORDER BY booking_id

Why this works

A plain SELECT from bookings with ORDER BY booking_id. All four columns come from the same table — no JOIN needed.

Success check

Returns one row per booking in stable booking order

Expected result

Use this output to verify values, aliases, ordering, and row count.

booking_idlisting_idnightsbooking_date
1132023-08-01
2252023-08-03
3322023-08-05
4442023-08-06
5532023-08-08
6122023-08-09
7642023-08-10
8512023-08-11
9322023-08-15
10132023-08-20

Previewing 10 of 11 expected rows. Run the query in the editor to inspect the full result.

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Interview Practice

Return to the complete interview preparation experience.