Chapter 5 · JOINs
62. Doctors with the Fewest Visits
Medium20 XPHealthcare
Scheduling wants to find doctors with the fewest visits. Return the doctor's full name (first_name || ' ' || last_name) as doctor_name, specialty, and visit_count. Include only doctors with fewer than 20 visits. Sort by visit_count ascending, then by doctor_name.
Tables
- PKidINT
- first_nameTEXT
- last_nameTEXT
- specialtyTEXT
- FKdepartment_id→ departments.idINT
- emailTEXT
- phoneTEXT
- hire_dateTEXT
- salaryREAL
- PKidINT
- FKpatient_id→ patients.idINT
- FKdoctor_id→ doctors.idINT
- visit_dateTEXT
- diagnosisTEXT
- notesTEXT
- follow_up_dateTEXT
- statusTEXT
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.