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
Join Patient Data Subset
00:00
5 left

Join Patient Data Subset

MediumSQL · PostgreSQL

Problem

Given a physical database diagram with three tables, write a query using inner joins to return a specific subset of patient data.

Return patients with an encounter during 2024 and a diagnosis code of E11.9 or I10. Include only records with matching patient, encounter, and diagnosis rows.

Output

  1. One row per matching patient diagnosis encounter
  2. Columns: patient_id, patient_name, encounter_date, diagnosis_code, and diagnosis_name
  3. Sort by encounter_date, then patient_id, then diagnosis_code

Schema

patients
ColumnTypeDescription
patient_idPKINTUnique patient identifier
full_nameVARCHAR(100)Patient's full name
medical_record_numberVARCHAR(20)Medical record number
sexVARCHAR(20)Recorded patient sex
insurance_member_idVARCHAR(30)Insurance member identifier
encounters
ColumnTypeDescription
encounter_idPKINTUnique encounter identifier
patient_idINTReferenced patient identifier
encounter_dateDATEDate of the encounter
encounter_typeVARCHAR(30)Type of clinical encounter
departmentVARCHAR(50)Clinical department
diagnoses
ColumnTypeDescription
diagnosis_idPKINTUnique diagnosis record identifier
encounter_idINTReferenced encounter identifier
diagnosis_codeVARCHAR(10)ICD diagnosis code
diagnosis_nameVARCHAR(100)Diagnosis description
Tablespatientsencountersdiagnoses
Interviewer

Your question is Join Patient Data Subset. 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.