Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Joins Across Tables

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

Your question is SQL Joins Across Tables. Start with the requirements and the three 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

Health Catalyst's Population Health workflows need a patient-level list of active patients with currently open care gaps. Write a PostgreSQL query that joins patient, care gap, and outreach action data.

Requirements

  1. Include only active patients with open care gaps due between January 1 and March 31, 2025.
  2. Return the patient name, region, number of distinct open care gaps, number of non-cancelled outreach actions, and most recent action date.
  3. Classify patients with two or more qualifying care gaps as high-touch; classify all others as standard.
  4. Include patients even when they have no qualifying outreach actions, then sort by care gap count descending and patient name ascending.

Schema

patients
ColumnTypeDescription
patient_idPKINTUnique patient identifier
patient_nameVARCHAR(100)Patient display name
regionVARCHAR(50)Care delivery region
is_activeBOOLEANWhether the patient is actively enrolled
enrollment_dateDATEDate the patient entered the program
care_gaps
ColumnTypeDescription
gap_idPKINTUnique care gap identifier
patient_idINTPatient associated with the gap
gap_typeVARCHAR(50)Clinical or preventive care gap type
statusVARCHAR(20)Current gap status
due_dateDATEDate by which the gap should be addressed
priorityVARCHAR(20)Operational priority
outreach_actions
ColumnTypeDescription
action_idPKINTUnique outreach action identifier
gap_idINTCare gap targeted by the action
action_statusVARCHAR(20)Status of the outreach action
action_dateDATEDate the action occurred
action_noteVARCHAR(200)Brief operational note
Tablespatientscare_gapsoutreach_actions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results