runtime
04 / 139

task NULL handling · warm-up

Appointments that produced no visit

Return appointment_id, patient_id and status for every appointment that has no linked encounter.

what to return

Columns
appointment_idpatient_idstatus in this order
Rows
2510 rows · any order
Skill
Find missing values with IS NULL. Refresher: Understand NULL →

expected result

Your query should return exactly these columns and values. Run it and compare.

expected result2510 rows · any order
appointment_idpatient_idstatus
11cancelled
81cancelled
265cancelled

first 3 of 2510 rows

data you can query

Healthcare dataset: the first 6 rows of each table. Under each column name: the kind of value it holds, and which table it links to. Your queries run on all rows.

appointments7 columns · 19,438 rows
appointment_idnumber · unique idpatient_idnumber · links to patientsprovider_idnumber · links to providersbooked_atdate & timescheduled_startdate & timestatustextencounter_idnumber · links to encounters
1142022-08-04 10:00:002022-08-04 13:00:00cancelledNULL
2142022-08-04 10:00:002022-08-07 13:00:00completed1
3142022-09-29 09:15:002022-10-12 11:15:00completed2
41742023-04-10 06:30:002023-05-12 11:30:00completed3
513492023-12-08 05:15:002023-12-17 08:15:00completed4
6142024-04-22 12:45:002024-05-09 16:45:00completed5
appointment_idnumber · unique id
1
patient_idnumber · links to patients
1
provider_idnumber · links to providers
4
booked_atdate & time
2022-08-04 10:00:00
scheduled_startdate & time
2022-08-04 13:00:00
statustext
cancelled
encounter_idnumber · links to encounters
NULL
appointment_idnumber · unique id
2
patient_idnumber · links to patients
1
provider_idnumber · links to providers
4
booked_atdate & time
2022-08-04 10:00:00
scheduled_startdate & time
2022-08-07 13:00:00
statustext
completed
encounter_idnumber · links to encounters
1
appointment_idnumber · unique id
3
patient_idnumber · links to patients
1
provider_idnumber · links to providers
4
booked_atdate & time
2022-09-29 09:15:00
scheduled_startdate & time
2022-10-12 11:15:00
statustext
completed
encounter_idnumber · links to encounters
2
appointment_idnumber · unique id
4
patient_idnumber · links to patients
1
provider_idnumber · links to providers
74
booked_atdate & time
2023-04-10 06:30:00
scheduled_startdate & time
2023-05-12 11:30:00
statustext
completed
encounter_idnumber · links to encounters
3
appointment_idnumber · unique id
5
patient_idnumber · links to patients
1
provider_idnumber · links to providers
349
booked_atdate & time
2023-12-08 05:15:00
scheduled_startdate & time
2023-12-17 08:15:00
statustext
completed
encounter_idnumber · links to encounters
4
appointment_idnumber · unique id
6
patient_idnumber · links to patients
1
provider_idnumber · links to providers
4
booked_atdate & time
2024-04-22 12:45:00
scheduled_startdate & time
2024-05-09 16:45:00
statustext
completed
encounter_idnumber · links to encounters
5

first 6 of 19,438 rows · your queries use all of them

solution.sql
 

Hints and the answer are always available. Using them counts the question as solved with help.

Appointments that produced no visit — SQL practice · Runtime