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_idstatusin 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_id | patient_id | status |
|---|---|---|
| 1 | 1 | cancelled |
| 8 | 1 | cancelled |
| 26 | 5 | cancelled |
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 id | patient_idnumber · links to patients | provider_idnumber · links to providers | booked_atdate & time | scheduled_startdate & time | statustext | encounter_idnumber · links to encounters |
|---|---|---|---|---|---|---|
| 1 | 1 | 4 | 2022-08-04 10:00:00 | 2022-08-04 13:00:00 | cancelled | NULL |
| 2 | 1 | 4 | 2022-08-04 10:00:00 | 2022-08-07 13:00:00 | completed | 1 |
| 3 | 1 | 4 | 2022-09-29 09:15:00 | 2022-10-12 11:15:00 | completed | 2 |
| 4 | 1 | 74 | 2023-04-10 06:30:00 | 2023-05-12 11:30:00 | completed | 3 |
| 5 | 1 | 349 | 2023-12-08 05:15:00 | 2023-12-17 08:15:00 | completed | 4 |
| 6 | 1 | 4 | 2024-04-22 12:45:00 | 2024-05-09 16:45:00 | completed | 5 |
- 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.