日期:2014-05-18 浏览次数:20471 次
;with ach as ( select convert(varchar(6),date,112) as date,sum(qty) as qty from tb group by convert(varchar(6),date,112) ) select a.date,cast(a.qty*100./nullif(b.qty,0) as decimal(6,2)) pe from ach a join ach b on datediff(mm,b.date+'01',a.date+'01') = 1