Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Month-over-Month Utilization Comparison
00:00
5 left

Month-over-Month Utilization Comparison

MediumSQL · PostgreSQL

Problem

Write a SQL query to compare each patient's current-month utilization against their previous-month utilization at Optum Technology. Use the provided patient and utilization data. Ignore utilization records with a NULL service date, and treat NULL utilization units as zero.

Output

  1. One row per patient whose current month immediately follows a month with recorded utilization.
  2. Return patient_id, patient_name, current_month, current_utilization, previous_utilization, utilization_change, and percent_change.
  3. Order by patient_id, then current_month ascending. If the previous utilization is zero, return NULL for percent_change.

Schema

patients
ColumnTypeDescription
patient_idPKINTUnique patient identifier
patient_nameVARCHAR(100)Patient's display name
utilization_records
ColumnTypeDescription
utilization_idPKINTUnique utilization record identifier
patient_idINTPatient associated with the utilization record
service_dateDATEDate on which utilization occurred
utilization_unitsNUMERIC(10,2)Units of healthcare utilization
Tablespatientsutilization_records
Interviewer

Your question is Month-over-Month Utilization Comparison. Start with the requirements and the two 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.