declare @t table(quesid int,userid int)
insert @t
select 1,1 union all
select 2,3 union all
select 3,4 union all
select 4,3 union all
select 5,4 union all
select 6,3 union all
select 7,2 union all
select 8,1
select userid
from @t
group by userid
order by sum(quesid) desc