SQL Challenges · WEEKLY QUACK CHALLENGE!

DUCK ELECTION NIGHT

Difficulty: medium

News Anchor Eider jabs a wing at the precinct map. Bill Duckson is already honking his victory speech — he piled up the most votes, no argument. But look at the map, Duckbert: he ran up the score in a few packed ponds and got out-paddled everywhere else. The night belongs to whoever carried the most precincts — pond by pond, race by race. Raw totals wont tell you. Find me the duck who won the map!

Your task

A precinct is carried by the candidate with the most votes in that precinct. Return the name of the candidate who carries the most precincts; on a tie, the alphabetically first. You will be working with the `votes` and `candidates` tables.

Tables

votes (27 rows)

columntype
precinct_idINTEGER
candidate_idINTEGER
countINTEGER

candidates (3 rows)

columntype
candidate_idINTEGER
nameVARCHAR

Database: https://dbquacks.com/data/databases/weekly_202632_06_election_night.duckdb

This page as markdown: https://dbquacks.com/challenges/weekly/6.md

Play this challenge →