BMS-HOSxP Community
HOSxP => Report Exchange => ข้อความที่เริ่มโดย: 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
-
order by pdxx ??? desc
-
ตามนี้เลยครับ
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