From 68456272e03b6357ab9ae251dd5e8a39da1e67a0 Mon Sep 17 00:00:00 2001 From: GMeghana123 <70551556+GMeghana123@users.noreply.github.com> Date: Sun, 29 Dec 2024 17:46:25 -0600 Subject: [PATCH 1/5] Add files via upload --- SQL1_HW.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 SQL1_HW.sql diff --git a/SQL1_HW.sql b/SQL1_HW.sql new file mode 100644 index 0000000..5ce0866 --- /dev/null +++ b/SQL1_HW.sql @@ -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 \ No newline at end of file From 34616a00bc121d817499091c6f8042c583c68cdb Mon Sep 17 00:00:00 2001 From: GMeghana123 Date: Sun, 29 Dec 2024 19:47:59 -0600 Subject: [PATCH 2/5] sql1 --- README.md | 5 ----- SQL1_HW.sql => sql_1.txt | 30 +++++++++++++++--------------- 2 files changed, 15 insertions(+), 20 deletions(-) delete mode 100644 README.md rename SQL1_HW.sql => sql_1.txt (92%) 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/SQL1_HW.sql b/sql_1.txt similarity index 92% rename from SQL1_HW.sql rename to sql_1.txt index 5ce0866..30d9163 100644 --- a/SQL1_HW.sql +++ b/sql_1.txt @@ -1,15 +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 \ No newline at end of file +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 From 097912d85606557302a85ed44e5a7744cce2b2dc Mon Sep 17 00:00:00 2001 From: GMeghana123 Date: Sun, 29 Dec 2024 19:57:24 -0600 Subject: [PATCH 3/5] sql1 --- sql_1.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sql_1.txt 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 From f77fd609081eed4539c9246c26efb81289e1ed3e Mon Sep 17 00:00:00 2001 From: GMeghana123 Date: Sun, 29 Dec 2024 20:09:17 -0600 Subject: [PATCH 4/5] Delete sql_1.txt --- sql_1.txt | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 sql_1.txt diff --git a/sql_1.txt b/sql_1.txt deleted file mode 100644 index 30d9163..0000000 --- a/sql_1.txt +++ /dev/null @@ -1,15 +0,0 @@ -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 From c098609d6ab4b87bcac185c4a46df8cd31c8c29c Mon Sep 17 00:00:00 2001 From: GMeghana123 Date: Sun, 29 Dec 2024 20:10:34 -0600 Subject: [PATCH 5/5] Create sql_1.txt --- sql_1.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sql_1.txt 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