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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Monthly Abnormal Results by Facility
00:00
5 left

Monthly Abnormal Results by Facility

MediumSQL · PostgreSQL

Problem

Can you explain how you would optimize a database for performance at 3Y Health?

For this hands-on SQL exercise, use the supplied PostgreSQL schema to produce the reporting result and explain performance improvements. Return only qualifying facilities and months.

Output

  1. One row per facility and calendar month.
  2. Columns: facility_id, facility_name, report_month, and abnormal_result_count.
  3. Include active patients' abnormal results from January through March 2025, keeping facility-month groups with at least two results.
  4. Order by report_month ascending, then facility_id ascending.

Schema

facilities
ColumnTypeDescription
facility_idPKINTFacility identifier
facility_nameVARCHAR(100)Facility name
patients
ColumnTypeDescription
patient_idPKINTPatient identifier
facility_idINTPrimary facility for the patient
statusVARCHAR(20)Patient status
lab_results
ColumnTypeDescription
result_idPKINTLab result identifier
patient_idINTPatient associated with the result
test_nameVARCHAR(80)Name of the laboratory test
resulted_atTIMESTAMPTimestamp when the result was recorded
is_abnormalBOOLEANWhether the result was outside the normal range
Tableslab_resultspatientsfacilities
Interviewer

Your question is Monthly Abnormal Results by Facility. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.