The patient portal needs to display visit history with doctor names. Return patient first_name, patient last_name, visit_date, and the doctor's full name (first_name || ' ' || last_name) as doctor_name. Join visits with patients and doctors. Order by visit_date descending.
Schema
🔑idINT
first_nameTEXT
last_nameTEXT
date_of_birthTEXT
genderTEXT
emailTEXT
phoneTEXTNULL
blood_typeTEXT
cityTEXT
stateTEXT
🔗insurance_idINTNULL
created_atTIMESTAMP
postgresql
Run your query to see results
Press Ctrl + Enter to execute