Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Complaint Driver Analysis
00:00
5 left

SQL for Complaint Driver Analysis

HardSQL · PostgreSQL

Problem

Write a SQL query to analyze daily guest complaints by property, category, and week at Caesars entertainment, and identify the top drivers of repeat complaints.

Use all available complaint records. A complaint is repeat when the same guest has previously complained at the same property and category. Treat Monday as the beginning of each week.

Output

  1. One row per property, category, week, and complaint date.
  2. Include property_name, category_name, week_start, complaint_date, daily_complaint_count, daily_repeat_count, weekly_repeat_count, and driver_rank.
  3. Include all categories with complaints, order by property, week, category, and date, and assign tied drivers the same rank.

Schema

properties
ColumnTypeDescription
property_idPKINTProperty identifier
property_nameVARCHAR(100)Caesars Entertainment property name
cityVARCHAR(80)Property city
guests
ColumnTypeDescription
guest_idPKINTGuest identifier
guest_nameVARCHAR(120)Guest display name
complaint_categories
ColumnTypeDescription
category_idPKINTComplaint category identifier
category_nameVARCHAR(80)Complaint category
guest_complaints
ColumnTypeDescription
complaint_idPKINTComplaint identifier
guest_idINTGuest who submitted the complaint
property_idINTProperty receiving the complaint
category_idINTComplaint category
complaint_dateDATEDate the complaint was submitted
statusVARCHAR(30)Complaint resolution status
notesTEXTOptional complaint notes
Tablespropertiesguestscomplaint_categoriesguest_complaints
Interviewer

Your question is SQL for Complaint Driver Analysis. Start with the requirements and the four 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.