BMS-HOSxP Community

HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: Guitar-hero ที่ กรกฎาคม 03, 2010, 17:30:27 PM

หัวข้อ: ถาม เซียนคำสั่ง sql หน่อยครับ
เริ่มหัวข้อโดย: Guitar-hero ที่ กรกฎาคม 03, 2010, 17:30:27 PM
คือ ต้องการแสดง ผู้ป่วยคลินิคเบาหวาน เฉพาะที่มีภาวะแทรกซ้อน ตามที่กำหนด และมี bp <= 130/80 
ตอนนี้เขียน เกือบเสร็จแล้ว แต่ติดอยู่ว่า อยากให้ นับ (count) ด้วยว่า ผู้ป่วยคลินิคเบาหวาน ที่มีค่า bp <=130 /80
ที่มารับบริการในช่วงเวลาที่กำหนด เป็นจำนวนกี่ครั้ง ไม่ทราบว่าจะต้อง count อย่างไร และ นี่คือคำสั่ง ที่ผมเขียน ขอให้ท่านเซียน sql ช่วยเพิ่มจำนวนนับ ให้หน่อยครับ


select ov.vstdate,ov.hn,concat(pt.pname,pt.fname,'  ',pt.lname) as pname,ov.pttypeno,
       ov.pttype,ptt.name as pttype_name,cl.clinic as clinic_code,cl.name as clinic_name


from ovst ov


left outer join patient pt on pt.hn = ov.hn

left outer join pttype ptt ON ptt.pttype = ov.pttype

left outer join clinicmember cm on cm.hn = ov.hn

left outer join clinic  cl on  cl.clinic = cm.clinic

left outer join clinic_cormobidity_list ccl on ccl.hn = ov.hn

left outer join clinic_cormobidity ccb on ccb.cormobidity = ccl.cormobidity

left outer join opdscreen oc on oc.hn = ov.hn

where cm.clinic='001' and ccl.cormobidity in('2','4','5','6')

      and (oc.bps!='' and oc.bw!='') and (oc.bps<=130 and oc.bw<80)

      and ov.vstdate between '2010-01-01' and '2010-01-30'

     
      GROUP BY ov.hn

หัวข้อ: Re: ถาม เซียนคำสั่ง sql หน่อยครับ
เริ่มหัวข้อโดย: เกื้อกูล ครับ.. ที่ กรกฎาคม 03, 2010, 20:32:08 PM
ก็คง count(vn) ของตาราง ovst นั่นแหล่ะครับ..เพราะเห็นมี group by  o.hn อยู่แล้ว...