this ought to do it:create table #temp(	competitor int,	points int) create table #results(	pos int identity(1,1),	competitor int,	total int)insert #temp ( competitor, points )	select 1, 1 union	select 1, 2 union	select 1, 3 union	select 2, 6 union	select 2, 7 union	select 2, 8 union	select 3, 8insert #results ( competitor, total )	select competitor, sum(points)	from #temp t	where not exists (		select 1		from #temp		where competitor = t.competitor and points > t.points		group by competitor		having count(*) > 1 ) 	group by competitor	order by sum(points) descselect * from #results
setBasedIsTheTruepath<O>