Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL for Guest Complaints
00:00
5 left

SQL for Guest Complaints

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze guest complaints by department and day, including joins between complaint, guest, and department tables.

Use all complaints dated from 2025-01-01 through 2025-01-05. Include complaints with missing guest or department matches, labeling missing departments as Unassigned.

Output

  1. One row per department and complaint day
  2. Columns: department_name, complaint_day, complaint_count, guest_count, urgent_complaint_count, and avg_resolution_hours
  3. Sort by department_name, then complaint_day ascending

Schema

complaints
ColumnTypeDescription
complaint_idPKINTUnique complaint identifier
guest_idINTGuest associated with the complaint
department_idINTDepartment responsible for the complaint
complaint_dateTIMESTAMPTimestamp when the complaint was recorded
severityVARCHAR(20)Complaint severity level
resolution_hoursNUMERIC(8,2)Hours required to resolve the complaint
guests
ColumnTypeDescription
guest_idPKINTUnique guest identifier
first_nameVARCHAR(80)Guest first name
last_nameVARCHAR(80)Guest last name
emailVARCHAR(255)Guest email address
departments
ColumnTypeDescription
department_idPKINTUnique department identifier
department_nameVARCHAR(100)Hotel operating department name
Tablescomplaintsguestsdepartments
Interviewer

Your question is SQL for Guest Complaints. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.