User77042963 posted
create table VoteCast (ID int identity(1,1),VoterId int, Candidate int)
Insert into VoteCast values (1002,2000), (1003,2000),(1004,2001),(1005,2000),(1006,2001),(1007,2002)
;with mycte as
(SELECT Candidate, count(*) AS Votes FROM VoteCast GROUP BY Candidate
)
select Candidate, Votes
, Case WHen dense_rank()Over(Order by Votes DESC) =1 Then 'Winner' Else 'Loser' End Status
from mycte
drop table VoteCast