select day(ghrq),count(djh) as sl,max('初诊')as xm from gh_sfdj where ctbz='0' and cf='0' group by day(ghrq)  
union select day(rq),count(id) as sl,max('咨询') as xm from t_czdhlyb where bz='0' group by day(rq)  
union select day(rq),count(id) as sl,max('留诊')as xm from t_czdhlyb where bz='0' and sflz='0' group by day(rq)  
union select day(rq),sum(case sflz='0' then 1 else 0 end)*100/count(id) as sl,max('比例')as xm  
from t_czdhlyb where bz='0' group by day(rq)  
unionselect day(ghrq),count(1) as sl,max('初诊+咨询') as xm from t_czdhlyb where (ctbz='0' and cf='0' )or bz='0' group by day(rq) 

解决方案 »

  1.   

    你好好看看 初诊是 gh_sfdj 表,咨询是t_czdhlyb 
    我先睡觉了,明天给你结贴。谢谢,慢慢冲个好澡
      

  2.   

    sorry 
    select day(ghrq),count(djh) as sl,max('初诊')as xm from gh_sfdj where ctbz='0' and cf='0' group by day(ghrq)  
    union select day(rq),count(id) as sl,max('咨询') as xm from t_czdhlyb where bz='0' group by day(rq)  
    union select day(rq),count(id) as sl,max('留诊')as xm from t_czdhlyb where bz='0' and sflz='0' group by day(rq)  
    union select day(rq),sum(case sflz='0' then 1 else 0 end)*100/count(id) as sl,max('比例')as xm  
    from t_czdhlyb where bz='0' group by day(rq)  
    unionselect rq,sum(sl),max('进号') as xm
    from(select day(ghrq) as rq,count(djh) as sl from gh_sfdj where ctbz='0' and cf='0' group by day(ghrq)  
    union 
    select day(rq),count(id) as sl from t_czdhlyb where bz='0' group by day(rq)) a
    group by rq
      

  3.   

    重薪诚聘C++ 
    http://topic.csdn.net/u/20080227/14/8bce0844-bd15-42f0-9cda-a343d5d6601b.html