Here's one way... 
--datadeclare @t table (MyGroup int, b int)insert @t select 1, 1union all select 1, 5union all select 1, 0union all select 1, 3union all select 2, 0union all select 2, 0union all select 2, 0union all select 2, 0union all select 3, 4union all select 3, 5union all select 3, 4union all select 3, 3--calculationselect MyGroup, isnull(avg(nullif(b, 0)), 0) as MyGroupAverage from @t group by MyGroup
Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part.