SELECT Count(SF.Filename) AS ‘Count0’
into #avge2
FROM dbo.v_GS_SoftwareFile SF
Where Filename like ‘%.exe’
GROUP BY SF.ResourceID

select avg(count0) from #avge2
drop table #avge2