日期:2014-05-18 浏览次数:20567 次
select ghrq as rq,count(djh) as sl,max('初诊')as xm from gh_sfdj
where ctbz='0' and cf='0' group by ghrq
union select yf_ckdj.rq,count(yf_ckdj.djh) as sl,max('化验人数') as xm from yf_ckdj,xt_sffm
where yf_ckdj.fpxm=xt_sffm.bm and xt_sffm.mc like '%化验%' group by yf_ckdj.rq
union select a.rq,case when a.sl=0 then -1 else b.sl/a.sl end as sl,
'化验人数/初诊' as xm
from
(select ghrq as rq,count(djh) as sl from gh_sfdj
where ctbz='0' and cf='0' group by ghrq ) a,
(select yf_ckdj.rq,count(yf_ckdj.djh) as sl from yf_ckdj,xt_sffm
where yf_ckdj.fpxm=xt_sffm.bm and xt_sffm.mc like '%化验%' group by yf_ckdj.rq ) b
where a.rq=b.rq