Student elections in SQL


Suppose a school is holding elections, with a small modification: in this voting system, students are allowed to vote for as many candidates as they like, with the caveat that each time they vote their vote is split. For example, if a given student votes for 1 candidate, that candidate receives 1 whole vote, whereas if the student votes for 2 candidates then both will receive 1/2 of a vote.

Given the following table along with the rules above, write a SQL query to determine which candidate won the election.

Table name: election_data

Voter Candidate
James Susan
James Jerry
John Susan
Lucy Alan
Terrance Susan
Terrance Alan
Howard Jerry


Access restricted

Subscribe to premium account to see the solution.

Get premium now