BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: panus_t ที่ สิงหาคม 26, 2011, 11:19:56 AM

หัวข้อ: ดู code รายงาน 10 อันดับโรคที่ ER ให้หน่อยครับ
เริ่มหัวข้อโดย: panus_t ที่ สิงหาคม 26, 2011, 11:19:56 AM
ดู code รายงาน 10 อันดับโรคที่ ER ให้หน่อยครับ
หาแบบนี้ถูกหรือเปล่าครับ หรือต้องหาที่ตาราง er_regist

select count(vn.pdx) as pdxx  ,count(distinct (vn.hn)) as sp1,vn.pdx,icd.name
from ovst ovst
left outer join vn_stat vn on vn.vn=ovst.vn
left outer join patient pt on pt.hn=vn.hn
left outer join icd101 icd on icd.code=vn.pdx
where  vn.vstdate between "2008-09-01" and  "2008-09-30" and vn.pdx  is not null and vn.pdx<>""
and ovst.main_dep="009"
group by vn.pdx
order by sp1   desc
limit 10
หัวข้อ: Re: ดู code รายงาน 10 อันดับโรคที่ ER ให้หน่อยครับ
เริ่มหัวข้อโดย: เกื้อกูล ครับ.. ที่ สิงหาคม 26, 2011, 13:29:48 PM
order  by  pdxx  ??? desc
หัวข้อ: Re: ดู code รายงาน 10 อันดับโรคที่ ER ให้หน่อยครับ
เริ่มหัวข้อโดย: yutbit ที่ สิงหาคม 26, 2011, 13:51:27 PM
ตามนี้เลยครับ

select count(vn.vn) as sp1,vn.pdx,icd.name
FROM
vn_stat AS vn
Left Outer Join icd101 AS icd ON icd.`code` = vn.pdx
Inner Join er_regist ON vn.vn = er_regist.vn
where  vn.vstdate between "2011-06-01" and  "2011-06-30" and vn.pdx  is not null and vn.pdx<>""
group by vn.pdx
order by sp1   desc
limit 10