Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Patients With No Follow-Up

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

Your question is Patients With No Follow-Up. 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

Providence care teams need to identify patients who completed an initial visit but have not completed a follow-up visit. Write a PostgreSQL query using the tables below.

Requirements

  1. Include only patients with at least one completed INITIAL visit.
  2. Exclude patients who have any completed FOLLOW_UP visit.
  3. Return each qualifying patient once, along with the date of their most recent completed initial visit.
  4. Order the results by patient_id ascending.

A scheduled or cancelled follow-up does not count as completed. Patients with no initial visit should not appear in the results.

Schema

patients
ColumnTypeDescription
patient_idPKINTEGERUnique patient identifier
patient_nameVARCHAR(100)Patient's display name
visits
ColumnTypeDescription
visit_idPKINTEGERUnique visit identifier
patient_idINTEGERReferences patients.patient_id
visit_typeVARCHAR(20)Visit classification
visit_statusVARCHAR(20)Current visit status
visit_dateDATEDate of the visit
Tablespatientsvisits
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results