Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Weekly Service KPI by Team

MediumSQL · PostgreSQL00:00
I
Practice interviewer
Your interviewer
In session
I
Interviewer

Welcome to the SQL screen.

The question is on your right: Weekly Service KPI by Team. Read through the requirements and the three tables first.

Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?

You need to log in / sign up to run or submit.

Problem

You are asked to write a PostgreSQL query to analyze service delivery performance by team from Deloitte operational reporting data. Return one row per team per week for completed service requests, showing total requests, on-time completions, average resolution hours, and a KPI status that labels each team-week as On Track, At Risk, or Needs Attention based on on-time rate and average resolution time.

Use the request creation week for grouping, include only requests created in January 2024, and exclude cancelled requests from the KPI calculations. The result should be sorted by week and team name.

Schema

ops_teams
ColumnTypeDescription
team_idPKINTPrimary key for the service delivery team
team_nameVARCHAR(100)Name of the team
regionVARCHAR(50)Region supported by the team
ops_agents
ColumnTypeDescription
agent_idPKINTPrimary key for the service agent
team_idINTTeam assignment for the agent
agent_nameVARCHAR(100)Agent full name
active_flagBOOLEANWhether the agent is currently active
ops_service_requests
ColumnTypeDescription
request_idPKINTPrimary key for the service request
agent_idINTAssigned agent for the request
created_atTIMESTAMPTimestamp when the request was created
completed_atTIMESTAMPTimestamp when the request was completed
due_atTIMESTAMPSLA due timestamp
statusVARCHAR(30)Current request status
priorityVARCHAR(20)Priority level of the request
Tablesops_teamsops_agentsops_service_requests
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results