Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Business Performance Metrics
00:00
5 left

SQL for Business Performance Metrics

HardSQL · PostgreSQL

Problem

Write a SQL query to analyze business performance at Tripadvisor by joining bookings, users, and support tickets, then aggregate key metrics by month and region. Include bookings and users with matching records, while preserving regions that have no support tickets. Use the booking month for monthly reporting and count each support ticket once.

Output

  1. One row per booking month and region, ordered by month ascending and region ascending.
  2. Columns: month, region, booking_count, total_booking_value, unique_users, support_ticket_count, and users_with_tickets.
  3. Include booking months and regions with zero support tickets.

Schema

users
ColumnTypeDescription
user_idPKINTUnique Tripadvisor user identifier
country_codeVARCHAR(2)Two-letter user country code
regionVARCHAR(40)Reporting region for the user
bookings
ColumnTypeDescription
booking_idPKINTUnique booking identifier
user_idINTUser who made the booking
booked_atDATEBooking date
amountNUMERIC(10,2)Booking value
support_tickets
ColumnTypeDescription
ticket_idPKINTUnique support ticket identifier
user_idINTUser who submitted the ticket
opened_atDATETicket creation date
statusVARCHAR(20)Current ticket status
Tablesbookingsuserssupport_tickets
Interviewer

Your question is SQL for Business Performance Metrics. Start with the requirements and the three tables in the Question tab.

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.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.