diff --git a/README.md b/README.md deleted file mode 100644 index 7b506fe..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Sql1 - -1. Problem 1: Big Countries (https://leetcode.com/problems/big-countries/) -2. Problem 2: Nth Highest Salary (https://leetcode.com/problems/nth-highest-salary/) -3. Problem 3: Delete Duplicate Emails (https://leetcode.com/problems/delete-duplicate-emails/) diff --git a/sql_1.txt b/sql_1.txt new file mode 100644 index 0000000..30d9163 --- /dev/null +++ b/sql_1.txt @@ -0,0 +1,15 @@ +Q1: +SELECT name, population, area FROM world WHERE area>=3000000 or population>=25000000 + +Q2: +CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT + + RETURN ( + WITH CTE AS( + SELECT *, DENSE_RANK()OVER(ORDER BY Salary DESC) as rankzz from employee + ) + SELECT DISTINCT salary from CTE where rankzz=n + ); + +Q3: +DELETE p1 from person p1 CROSS JOIN person p2 where p1.email=p2.email and p1.id>p2.id