Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Bottlenecks by Team and Week

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

Your question is SQL Bottlenecks by Team and Week. Start with the requirements and the two 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

Private Practice wants to identify operational bottlenecks that take the longest to resolve. Write a PostgreSQL query that summarizes resolved cases by team, calendar week, and bottleneck type, then returns the five groups with the highest average resolution time.

Requirements

  1. Join operational_cases to teams and group results by team, week, and bottleneck type.
  2. Include only resolved cases with non-null timestamps and bottleneck types.
  3. Calculate average resolution time in hours and the number of resolved cases in each group.
  4. Return the five highest averages, using a deterministic tie-breaker after sorting by average resolution time descending.

Representative Data

Schema

teams
ColumnTypeDescription
team_idPKINTUnique operations team identifier
team_nameVARCHAR(100)Private Practice operations team name
operational_cases
ColumnTypeDescription
case_idPKINTUnique operational case identifier
team_idINTAssigned operations team identifier
bottleneck_typeVARCHAR(100)Category describing the operational bottleneck
created_atTIMESTAMPTimestamp when the case was created
resolved_atTIMESTAMPTimestamp when the case was resolved
statusVARCHAR(20)Current case status
Tablesteamsoperational_cases
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results