Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Analyzing Nursing Data with SQL

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

Your question is Analyzing Nursing Data with SQL. 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

Tell me about a time you completed a CMS data case study and used SQL to analyze nursing data.

For this exercise, write a SQL query that analyzes active nursing facilities and their 2024 registered-nurse staffing records. Calculate each facility's valid reporting months and average RN hours per resident day. Treat zero resident days and missing RN hours as invalid measurements.

Output

  1. One row per active facility, including facilities without valid records.
  2. Columns: facility_name, state, months_reported, avg_rn_hours_per_resident_day, and staffing_band.
  3. Classify facilities with at least two valid months and an average of at least 0.030 as Meets benchmark, other facilities with at least two valid months as Below benchmark, and all others as Insufficient data.
  4. Order by state ascending, then facility name ascending.

Schema

nursing_facilities
ColumnTypeDescription
facility_idPKINTUnique nursing facility identifier
facility_nameVARCHAR(100)Facility name
stateVARCHAR(2)Two-letter facility state code
is_activeBOOLEANWhether the facility is currently active
nursing_staffing_monthly
ColumnTypeDescription
staffing_record_idPKINTUnique monthly staffing record identifier
facility_idINTReferenced nursing facility
record_monthDATEFirst day of the reporting month
rn_hoursDECIMAL(10,2)Registered-nurse hours reported for the month
resident_daysINTTotal resident days for the month
Tablesnursing_facilitiesnursing_staffing_monthly
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results