日期:2014-05-17 浏览次数:20713 次
select a.iYear, a.iMonth, a.num/case b.num when 0 then null else b.num from ( select cast(count(*)as decimal)num ,datepart(year,tb_jbkhb.gcsj) iYear ,datepart(month,tb_jbkhb.gcsj) iMonth from tb_jbkhb group by datepart(year,tb_jbkhb.gcsj),datepart(month,tb_jbkhb.gcsj) ) a inner join ( select cast(count(*)as decimal)num,datepart(year,tb_yxgzb.gcsj) iYear ,datepart(month,tb_yxgzb.gcsj)iMonth from tb_yxgzb group by datepart(year,tb_yxgzb.sjjdsj),datepart(month,tb_yxgzb.sjjdsj) ) b on a.iYear=b.iYear and a.iMonth=b.iMonth