201
Report Exchange / Re: ขอรายงานหน่อยครับท่าน
« เมื่อ: กันยายน 29, 2011, 15:36:12 PM »
select a.hn,p.pname,p.fname,p.lname
,a.nextdate
,c.name as clinic,k.department,a.doctor, d.name as doctorname
,concat(p.addrpart,' ม.',p.moopart,' ',t.full_name) address
from oapp a
left join patient p on a.hn=p.hn
left join clinic c on c.clinic=a.clinic
left join doctor d on d.code=a.doctor
left join kskdepartment k on k.depcode = a.depcode
left join thaiaddress t on t.addressid=concat(p.chwpart,p.amppart,p.tmbpart)
where a.nextdate between '2011-9-1' and '2011-9-30'
and (a.patient_visit<>'Y' or a.patient_visit is null)
group by a.hn,a.nextdate
,a.nextdate
,c.name as clinic,k.department,a.doctor, d.name as doctorname
,concat(p.addrpart,' ม.',p.moopart,' ',t.full_name) address
from oapp a
left join patient p on a.hn=p.hn
left join clinic c on c.clinic=a.clinic
left join doctor d on d.code=a.doctor
left join kskdepartment k on k.depcode = a.depcode
left join thaiaddress t on t.addressid=concat(p.chwpart,p.amppart,p.tmbpart)
where a.nextdate between '2011-9-1' and '2011-9-30'
and (a.patient_visit<>'Y' or a.patient_visit is null)
group by a.hn,a.nextdate