Margin of Victory per Region
Hard
Elections & Voting
For each region return the winning candidate and the margin (winner votes minus runner-up votes). Assume no tie for first. Order by region.
Table schema
Votes(voter_id INT PRIMARY KEY, candidate VARCHAR(5), region VARCHAR(5))Sample data
voter_id | candidate | region
1 | X | N
2 | X | N
3 | Y | N
4 | Y | S
5 | Z | S
6 | Y | S
7 | X | S
8 | Z | N
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.