Skip to content
Open
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
29 changes: 29 additions & 0 deletions SQL1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Problem 1: Big Countries (https://leetcode.com/problems/big-countries/)
# Write your MySQL query statement below
SELECT name, population, area
FROM World
WHERE area >= 3000000 OR population >= 25000000;

# Problem 2: Nth Highest Salary (https://leetcode.com/problems/nth-highest-salary/)
# Write your MySQL query statement below
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
RETURN (
# Write your MySQL query statement below.
WITH TEMP AS
(
SELECT id, salary, DENSE_RANK() OVER(ORDER BY salary DESC) AS ranks
FROM Employee
)
SELECT IFNULL(salary, null)
FROM TEMP
WHERE ranks = N
);
END

# Problem 3: Delete Duplicate Emails (https://leetcode.com/problems/delete-duplicate-emails/)
# Write your MySQL query statement below
DELETE p2
FROM Person p1
JOIN Person p2
ON p1.email = p2.email AND p2.id > p1.id