Winning Candidate

4pts
Uber

Problem Statement

The election is over, and it is time to announce the winner. You are given two tables: Candidate and Vote.

Write an SQL query to find the name of the winning candidate.

Rules:

  • The winning candidate is the one with the most votes.
  • You may assume there is only one winner (no ties).
  • Output columns: name.
  • Result should be the name of the person with the most votes.
Tests your understanding of
Joins, Aggregation and Sorting

Input Tables

Candidate
id(INTEGER)name(VARCHAR)
1Alice
2Bob
3Charlie
Vote
candidate_id(INTEGER)
2
3
3
2
2
Election_Metadata
region(VARCHAR)
North

Expected Output

name(VARCHAR)
Bob

Tags

MediumJoinsAggregationSorting
15-20 min
52%

Hints