SQL อันดับโรค 0-5 ปี OPD IPD
Post By : tharatip
IP Address : 180.180.165.111
OPD
select a.pdx,count(a.pdx) as pdx_count ,i.name as icdname
from vn_stat a
left outer join icd101 i on i.code=a.main_pdx
where a.vstdate between '201-08-01' and '2011-08-31'
and a.pdx<>'' and a.pdx is not null
and a.age_y >= 0
and a.age_y <= 5
group by a.pdx,i.name
order by pdx_count desc
IPD
select v.pdx,count(v.pdx) as pdx_count, i.name as icdname
from an_stat v
left outer join icd101 i on i.code=v.pdx
where v.dchdate between "2011-01-01" and "2011-01-31" and v.pdx is not null and v.pdx<>""
and v.age_y>= 0
and v.age_y<= 5
group by v.pdx,i.name
order by pdx_count desc