Thursday, February 14, 2013

SQL นัด Clinic DM&HT มาตรวจ Lab ประจำปี


DM ในเขต 

SELECT o.nextdate,o.hn,CONCAT(p.pname,p.fname,"  ",p.lname) as ptname,o.note,o.app_user ,
v.village_id,v.village_moo,v.village_name
FROM oapp o
LEFT OUTER JOIN patient p on p.hn=o.hn
LEFT OUTER JOIN person s on s.patient_hn=o.hn
LEFT OUTER JOIN clinicmember c on c.hn=o.hn
LEFT OUTER JOIN village v on v.village_id=s.village_id
WHERE nextdate in ("2013-04-02","2013-04-09") and s.village_id <> "1" and c.clinic = "001"
ORDER BY o.nextdate,v.village_id


HT ในเขต

SELECT o.nextdate,o.hn,CONCAT(p.pname,p.fname,"  ",p.lname) as ptname,o.note,o.app_user ,
v.village_id,v.village_moo,v.village_name
FROM oapp o
LEFT OUTER JOIN patient p on p.hn=o.hn
LEFT OUTER JOIN person s on s.patient_hn=o.hn
LEFT OUTER JOIN clinicmember c on c.hn=o.hn
LEFT OUTER JOIN village v on v.village_id=s.village_id
WHERE nextdate in ("2013-04-23") and s.village_id <> "1" and c.clinic = "003"
ORDER BY o.nextdate,v.village_id

#keepper

0 ความคิดเห็น:

Post a Comment

 

Sample Text

111

Sample Text