SQL: Today’s No Shows with Previous No Show Activity

About

This report shows list of patients who no-showed today, along with their no-show list prior to today.

A sample image of this SQL report run in the Database Viewer is shown below:

Caveats

Includes both hard (“No Show”) and soft (“No Show*) statuses.

Code

To highlight and copy the code below to your clipboard, simply click the Copy button.

select a.*, old_no_show from	
(	
select patno, fname, lname, appt_date from schedule	
inner join register on register.patno = schedule.patno	
where cast('today' as date) = appt_date and patno >99 and visit_status like '%No Show%'	
) a	
left outer join (select cast(list(appt_date) as char(2000)) as old_no_show, patno from schedule where visit_status like '%No Show%' and appt_date < cast('today' as date) and patno in	
(select patno from schedule	
inner join register on register.patno = schedule.patno	
where cast('today' as date) = appt_date and patno >99 and visit_status like '%No Show%') group by patno	
) s on a.patno = s.patno