Skip to content

Commit 2f9bfd2

Browse files
authored
Create the-winner-university.sql
1 parent 1111e02 commit 2f9bfd2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

MySQL/the-winner-university.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Time: O(n)
2+
# Space: O(n)
3+
4+
WITH nyu_cte AS (
5+
SELECT COUNT(*) AS cnt FROM NewYork WHERE score >= 90
6+
), cu_cte AS (
7+
SELECT COUNT(*) AS cnt FROM California WHERE score >= 90
8+
)
9+
10+
SELECT
11+
(CASE
12+
WHEN N.cnt > C.cnt THEN 'New York University'
13+
WHEN N.cnt < C.cnt THEN 'California University'
14+
ELSE 'No Winner'
15+
END) AS winner
16+
FROM nyu_cte N, cu_cte C;

0 commit comments

Comments
 (0)