Select 维修人,维修编码,Cast((a.次数/(tmp.次数+0.00)) as decimal(8,2)) as 次数 from (Select 维修编码,次数=Count(*) from table Group by 维修编码)tmp,table a where tmp.维修编码=a.维修编码
select 维修人,维修编码,cast(sum(1)/(select sum(1)+0.0 from 你的表 where 单据号 in (select 单据号 from 你的表 where 维修人=tem.维修人 and 维修编码=tem.维修编码)) as numeric(10,2)) 次数 from 你的表 tem group by 维修人,维修编码