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_idINTEGERlisting_idINTEGERnightsINTEGERbooking_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_idWhy 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_id | listing_id | nights | booking_date |
|---|---|---|---|
| 1 | 1 | 3 | 2023-08-01 |
| 2 | 2 | 5 | 2023-08-03 |
| 3 | 3 | 2 | 2023-08-05 |
| 4 | 4 | 4 | 2023-08-06 |
| 5 | 5 | 3 | 2023-08-08 |
| 6 | 1 | 2 | 2023-08-09 |
| 7 | 6 | 4 | 2023-08-10 |
| 8 | 5 | 1 | 2023-08-11 |
| 9 | 3 | 2 | 2023-08-15 |
| 10 | 1 | 3 | 2023-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
Explore related company challenges
Uber
Independent Uber-style mobility marketplace SQL practice covering trips, drivers, riders, pricing, payments, and promotions.
Amazon
Independent Amazon-style e-commerce, warehouse, inventory, and customer analytics SQL practice.
Meta
Independent Meta-style social-product, engagement, content, community, messaging, and advertising SQL practice.
Return to the complete interview preparation experience.