Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Staffing Performance Analysis
00:00
5 left

SQL for Staffing Performance Analysis

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze staffing performance by site, date, and shift, including joins across staffing, schedules, and attendance tables.

Use schedules as the required shift-level grain and analyze dates from 2025-06-01 through 2025-06-03. Include shifts without staffing records and calculate staffing fill and attendance rates.

Output

  1. One row per site, work date, and shift within the date range
  2. Columns: site_name, work_date, shift, scheduled_headcount, staffed_count, attended_count, fill_rate_pct, attendance_rate_pct
  3. Sort by site_name, work_date, and shift ascending

Schema

schedules
ColumnTypeDescription
schedule_idPKINTUnique scheduled shift identifier
site_nameVARCHAR(100)Delaware Staffing client site
work_dateDATEDate of the scheduled shift
shiftVARCHAR(20)Shift label
scheduled_headcountINTNumber of workers requested for the shift
staffing
ColumnTypeDescription
staffing_idPKINTUnique staffing assignment identifier
schedule_idINTScheduled shift receiving the assignment
worker_idVARCHAR(20)Assigned worker identifier
assignment_statusVARCHAR(20)Assignment state
attendance
ColumnTypeDescription
attendance_idPKINTUnique attendance record identifier
schedule_idINTScheduled shift associated with attendance
worker_idVARCHAR(20)Worker whose attendance was recorded
attendance_statusVARCHAR(20)Attendance outcome
Tablesschedulesstaffingattendance
Interviewer

Your question is SQL for Staffing Performance Analysis. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.