Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top Three Longest Resolutions

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

Your question is Top Three Longest Resolutions. Start with the requirements and the three tables 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

ASML service teams want to identify the longest-resolving customer support issues for each operating region. Write a PostgreSQL query that ranks resolved tickets by resolution time within each region.

Requirements

  1. Join tickets to customer sites and regions using their foreign-key relationships.
  2. Calculate resolution time in hours from created_at to resolved_at.
  3. Exclude unresolved tickets and tickets without a valid region.
  4. Return no more than the three longest-resolving tickets per region, ordered by region and resolution time descending. Break ties with the ticket ID.

Schema

support_tickets
ColumnTypeDescription
ticket_idPKINTUnique support ticket identifier
site_idINTCustomer site associated with the ticket
issue_titleVARCHAR(150)Short description of the support issue
statusVARCHAR(20)Current ticket status
created_atTIMESTAMPTimestamp when the ticket was created
resolved_atTIMESTAMPTimestamp when the ticket was resolved
customer_sites
ColumnTypeDescription
site_idPKINTUnique customer site identifier
site_nameVARCHAR(100)Customer or facility site name
region_codeVARCHAR(10)Region assigned to the site
regions
ColumnTypeDescription
region_codePKVARCHAR(10)Unique region code
region_nameVARCHAR(100)Readable region name
Tablessupport_ticketscustomer_sitesregions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results