Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL: Top Sites by Unresolved Tickets

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

Your question is SQL: Top Sites by Unresolved Tickets. 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

Write a SQL query to join work orders, sites, and client tables to find the top 10 sites by unresolved tickets in the last 30 days.

Use the provided tables and return only tickets created within the last 30 days whose status is unresolved. Treat open, in_progress, and pending as unresolved statuses.

Output

  1. One row per site, including site_id, site_name, client_name, and unresolved_ticket_count
  2. Include only sites with at least one qualifying ticket
  3. Sort by ticket count descending, then site_id ascending for ties
  4. Return at most 10 rows

Schema

work_orders
ColumnTypeDescription
work_order_idPKINTUnique work order identifier
site_idINTSite associated with the work order
client_idINTClient associated with the work order
statusVARCHAR(30)Current work order status
created_atTIMESTAMPTimestamp when the work order was created
sites
ColumnTypeDescription
site_idPKINTUnique site identifier
site_nameVARCHAR(150)Site display name
client_idINTClient responsible for the site
clients
ColumnTypeDescription
client_idPKINTUnique client identifier
client_nameVARCHAR(150)Client display name
Tableswork_orderssitesclients
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results