พอดีพยาบาลอยากได้รายงานเด็กเลื่อนนัด ผมมีรายงานเด็กมาตามนัด กับ เด็กขาดนัดแล้ว แต่พยาบาลอยากได้ เด็กเลื่อนนัดอีก 1 รายงาน ไม่ทราบว่าจะเขียนคำสั่งอย่างไรดีครับ
คำสั่งเด็กมาตามนัด
select o.nextdate,o.hn,concat(pt.pname,pt.fname," ",pt.lname)as ptname,concat("นาย",pt.fathername," ",pt.fatherlname)as father,
concat("นาง",pt.mathername," ",pt.motherlname)as mother,
concat(pt.addrpart," หมู่ ",pt.moopart)as addressname,concat("ต.",t3.name," อ.",t2.name," จ.",t1.name) as fulladdressname,o.person_vaccine_id from oapp o
left outer join patient pt on pt.hn=o.hn
left outer join thaiaddress t1 on t1.chwpart=pt.chwpart
and t1.amppart="00" and t1.tmbpart="00"
left outer join thaiaddress t2 on t2.chwpart=pt.chwpart
and t2.amppart=pt.amppart and t2.tmbpart="00"
left outer join thaiaddress t3 on t3.chwpart=pt.chwpart
and t3.amppart=pt.amppart and t3.tmbpart=pt.tmbpart
where o.nextdate between "2014-08-01" and "2014-08-31"
and o.person_vaccine_id in ("5","6","7","8","38","39","40","12","13","14","15","16","19","20","21","17","22","18","23")
order by o.nextdate
คำสั่งเด็กขาดนัด
select o.nextdate,o.hn,concat(pt.pname,pt.fname," ",pt.lname)as ptname,concat("นาย",pt.fathername," ",pt.fatherlname)as father,
concat("นาง",pt.mathername," ",pt.motherlname)as mother,
concat(pt.addrpart," หมู่ ",pt.moopart)as addressname,concat("ต.",t3.name," อ.",t2.name," จ.",t1.name) as fulladdressname,o.person_vaccine_id from oapp o
left outer join patient pt on pt.hn=o.hn
left outer join thaiaddress t1 on t1.chwpart=pt.chwpart
and t1.amppart="00" and t1.tmbpart="00"
left outer join thaiaddress t2 on t2.chwpart=pt.chwpart
and t2.amppart=pt.amppart and t2.tmbpart="00"
left outer join thaiaddress t3 on t3.chwpart=pt.chwpart
and t3.amppart=pt.amppart and t3.tmbpart=pt.tmbpart
where o.nextdate between "2014-08-01" and "2014-08-31"
and o.hn not in (select hn from ovst where vstdate between '2014-09-01' and '2014-09-19' )
and o.person_vaccine_id in ("5","6","7","8","38","39","40","12","13","14","15","16","19","20","21","17","22","18","23")
order by o.nextdate
อยากได้คำสั่ง เลื่อนนัด ครับ ไม่ทราบว่าใช้คำสั่ง sql อย่างไงครับ