Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL for User Booking Data

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL for User Booking Data. Start with the requirements and the one table on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Create a SQL query to extract user booking data for analysis.

Return every booking as one result row, preserving NULL values where the source data has them. Sort the results by user, booking date, and booking ID.

Output

  1. One row per booking
  2. Columns: booking_id, user_id, booking_date, destination, booking_status, and total_amount
  3. Sort by user_id ascending, booking_date ascending, and booking_id ascending

Schema

bookings
ColumnTypeDescription
booking_idPKINTUnique booking identifier
user_idINTIdentifier of the user who made the booking
booking_dateDATEDate when the booking was created
destinationVARCHAR(100)Booking destination
booking_statusVARCHAR(30)Current status of the booking
total_amountDECIMAL(10,2)Total booking amount
Tablesbookings
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results