Skip to content

Commit 23894c5

Browse files
committed
Upload 196
1 parent addf965 commit 23894c5

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- markdownlint-disable MD041 -->
22
[![eevveerryyddaayy release](https://img.shields.io/badge/eevveerryyddaayy-v1.3.0-blue.svg)](https://github.com/ggeerraarrdd/eevveerryyddaayy/)
3-
[![Solved](https://img.shields.io/badge/solved-195-green.svg)](#index)
3+
[![Solved](https://img.shields.io/badge/solved-196-green.svg)](#index)
44
<!-- markdownlint-enable MD041 -->
55

66
# SQL Everyday
@@ -229,6 +229,7 @@ Because this project necessitated a framework to enable consistent daily practic
229229
| 193 | [Classifying Triangles by Lengths](https://leetcode.com/problems/classifying-triangles-by-lengths/description/) | [Solution](solutions/193_classifying_triangles_by_lengths.md) | LeetCode | Easy | |
230230
| 194 | [Reported Posts](https://leetcode.com/problems/reported-posts/description/) | [Solution](solutions/194_reported_posts.md) | LeetCode | Easy | |
231231
| 195 | [Game Play Analysis III](https://leetcode.com/problems/game-play-analysis-iii/description/) | [Solution](solutions/195_game_play_analysis_iii.md) | LeetCode | Medium | |
232+
| 196 | [Winning Candidate](https://leetcode.com/problems/winning-candidate/description/) | [Solution](solutions/196_winning_candidate.md) | LeetCode | Medium | |
232233
<!-- Index End - WARNING: Do not delete or modify this markdown comment. -->
233234
<!--- cSpell:enable --->
234235

solutions/196_winning_candidate.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# SQL Everyday \#196
2+
3+
## Winning Candidate
4+
5+
Site: LeetCode\
6+
Difficulty per Site: Medium
7+
8+
## Problem
9+
10+
Write a solution to report the name of the winning candidate (i.e., the candidate who got the largest number of votes).
11+
12+
The test cases are generated so that **exactly one candidate wins** the elections. [[Full Description](https://leetcode.com/problems/winning-candidate/description/)]
13+
14+
## Submitted Solution
15+
16+
```sql
17+
-- Submitted Solution
18+
WITH cte AS (
19+
SELECT
20+
c.name
21+
,COUNT(v.id) AS votes
22+
FROM Vote AS v
23+
JOIN Candidate AS c ON v.candidateId = c.id
24+
GROUP BY c.name
25+
ORDER BY votes DESC
26+
LIMIT 1
27+
)
28+
SELECT
29+
name
30+
FROM cte
31+
;
32+
```
33+
34+
## Site Solution
35+
36+
```sql
37+
-- LeetCode Solution
38+
-- Site solution essentially the same
39+
```
40+
41+
## Notes
42+
43+
TBD
44+
45+
## NB
46+
47+
TBD
48+
49+
Go to [Index](../?tab=readme-ov-file#index)\
50+
Go to [Overview](../?tab=readme-ov-file)

0 commit comments

Comments
 (0)