SQL: Appointments Scheduled by Staff Member for Period

There are two versions of this SQL: Firebird and MySQL. The MySQL version only applies to clients who are have migrated to MySQL.. All other Practices should continue to use the Firebird version of this code. Click to expand and copy the code you need. If you are unsure which code to use, please check with your Practice Administrator.

About

This report shows all appointments scheduled, and by which staff member, for a period between two specified dates.

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

Caveats

If an appointment is moved, the person who originally scheduled the appointment will be listed (not the person who moved the appointment).  For example, if Wanda scheduled the appointment, but then Bertha later moved it, this will show Wanda’s name, not Bertha’s.

SQL Code: Firebird

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

select staffname as scheduled_by, dateadd(minute,start_time,appt_date) as appt_time, code1, schedule.patno, schedule.uniqkey as appt_unique_number from schedule 
inner join staff1 on staff1.staffid = schedule.s_addr_id
where appt_date between :start_date and :end_Date


SQL Code: MySQL

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

select staffname as scheduled_by, date_add(cast(appt_date as datetime), interval start_time minute) as appt_time, code1, schedule.patno, schedule.uniqkey as appt_unique_number from schedule 
inner join staff1 on staff1.staffid = schedule.s_addr_id
where appt_date between :start_date and :end_date and patno >0