runtime
72 / 139

task LEFT JOIN · easy

Predict: patients with and without missed appointments

Predict every row returned when the six sample patients are LEFT JOINed to their cancelled or missed appointments.

what to return

Columns
patient_idstatus in this order
Rows
in the order asked
Watch for
Use only the sample rows shown. NULL is not zero or empty text. Keep duplicate rows.
Skill
Reason about the exact result of a fixed SQL query. Refresher: Keep unmatched rows →

data you can query

patient_sample2 columns · 6 rows
patient_idinsurance_type
1medicaid
2medicare
3medicaid
4commercial
5medicaid
6medicare
patient_id
1
insurance_type
medicaid
patient_id
2
insurance_type
medicare
patient_id
3
insurance_type
medicaid
patient_id
4
insurance_type
commercial
patient_id
5
insurance_type
medicaid
patient_id
6
insurance_type
medicare

all 6 rows

missed_appointments3 columns · 8 rows
appointment_idpatient_idstatus
11cancelled
81cancelled
265cancelled
295cancelled
346no_show
356no_show
386cancelled
436no_show
appointment_id
1
patient_id
1
status
cancelled
appointment_id
8
patient_id
1
status
cancelled
appointment_id
26
patient_id
5
status
cancelled
appointment_id
29
patient_id
5
status
cancelled
appointment_id
34
patient_id
6
status
no_show
appointment_id
35
patient_id
6
status
no_show
appointment_id
38
patient_id
6
status
cancelled
appointment_id
43
patient_id
6
status
no_show

all 8 rows

predict.sql
SELECT p.patient_id, a.status
FROM patient_sample p
LEFT JOIN missed_appointments a ON a.patient_id = p.patient_id
ORDER BY p.patient_id, a.appointment_id
prediction.json

Enter the rows you think the query returns, column order patient_id, status. JSON array of rows — numbers bare, text in quotes, null for NULL. Example: [ [ 1, null ] ]. Keep ORDER BY order.

 
Output

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

Predict: patients with and without missed appointments — SQL practice · Runtime