Hi there.Is this what youre looking for? Anytime you use a TOP operator you should be sure to implement an ORDER BY as well. Otherwise, you are rolling the dice. Notice how I moved your ORDER BY into your 2nd SELECT that uses the TOP.Anyways, as you mentioned, you can do this in one query.declare @tblSync table (tID int identity(1,1), tFrom varchar(10)) insert into @tblSync select 'Nathan' union all select 'Nathan' union all select 'Nathan' union all select 'Arlene' union all select 'Arlene' union all select 'msconus2'declare @WebTemp table (tFrom varchar(10), WebFormCount int)----------------------------------------------------- your query---------------------------------------------------insert into @WebTempselect tFrom, count(1) as WebFormCount from @tblSyncwhere tFrom not like 'msconus%'group by tFrom --order --by WebFormCount descselect top 1 tFrom, WebFormCount from @webtemporder by WebFormCount desc----------------------------------------------------- new query---------------------------------------------------select top 1 tFrom, count(*)from @tblSyncwhere tFrom not like 'msconus%'group by tFromorderby count(*) desc
Nathan Skerl