Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 01-BigCountries.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Problem 1: Big Countries (https://leetcode.com/problems/big-countries/)
select name, population, area
from world
where area >= 3000000 or population >=25000000
16 changes: 16 additions & 0 deletions 02-NthHighestSalary.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Problem 2: Nth Highest Salary (https://leetcode.com/problems/nth-highest-salary/)

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
RETURN (
# Write your MySQL query statement below.
with cte as (
select salary, dense_rank()
over (order by salary desc) as rnk
from employee
)
select distinct ifnull(salary, null)
from cte
where rnk=N
);
END
5 changes: 5 additions & 0 deletions 03-DeleteDuplicateEmails.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Problem 3: Delete Duplicate Emails (https://leetcode.com/problems/delete-duplicate-emails/)

delete p1 from person p1
cross join person p2
where p1.email = p2.email and p1.id > p2.id