SET NOCOUNT ON
SELECT
a.AppointmentsId,
ISNULL(Convert(VarChar(20), a.ApptStart, 101),'')as ApptDate,
ISNULL(Convert(VarChar(20), a.ApptStart, 108),'')as ApptTime,
res.listname AS ApptResource,
fac.listname AS ApptFacility,
apt.Name AS AppointmentType,
isnull(aps.description, '') + ' ' + isnull(a.status, '') as ApptStatus
FROM
Appointments a
LEFT JOIN doctorfacility res ON a.ResourceID = res.doctorfacilityID
LEFT JOIN doctorfacility fac ON a.facilityID = fac.doctorfacilityID
LEFT JOIN appttype apt ON a.appttypeID = apt.appttypeID
LEFT JOIN medlists aps ON a.apptStatusMID = aps.medlistsID
WHERE
a.OwnerId = '48'
|