--门诊每个科室主诊断排名(日期自行修改:取挂号日期): select a.jzks00,count(*),trim(icd900),trim(a.zdmc00) from ys_brzdxx a,sf_brxxb0 b where a.ghh000=b.ghh000 and a.zzdbz0='3' and b.ghrq00>='20140801' and b.ghrq00<='20140831' group by a.jzks00,trim(icd900),trim(a.zdmc00) order by a.jzks00 ,count(*) desc --住院每个病区主诊断排名(日期自行修改:取出院日期): select b.dqbq00,count(*),trim(zdm000),trim(a.zdmc00) from bq_brzdxx a,zy_brxxb0 b where a.zyid00=b.zyid00 and a.zdlb00='3' and b.cyrq00>='20140801' and b.cyrq00<='20140831' group by b.dqbq00,trim(zdm000),trim(a.zdmc00) order by b.dqbq00,count(*) desc