For each patient's visits (completed only), calculate the number of days since their previous visit. Return patient_id, visit_date, the previous visit date, and the gap in days. Order by patient_id and visit_date.
Schema
🔑idINT
🔗patient_idINT
🔗doctor_idINT
visit_dateTEXT
diagnosisTEXT
notesTEXTNULL
follow_up_dateTEXTNULL
statusTEXT
postgresql
Run your query to see results
Press Ctrl + Enter to execute