From ca4b8c05a455eb33d4e2b1ed0c9c2814d3d3ae6a Mon Sep 17 00:00:00 2001 From: Sai Rohith Kongari Date: Mon, 2 Jun 2025 10:47:39 -0500 Subject: [PATCH] Done Sql1 --- Sql_Solutions/Problem1.sql | 3 +++ Sql_Solutions/Problem3.sql | 3 +++ Sql_Solutions/problem2.sql | 9 +++++++++ 3 files changed, 15 insertions(+) create mode 100644 Sql_Solutions/Problem1.sql create mode 100644 Sql_Solutions/Problem3.sql create mode 100644 Sql_Solutions/problem2.sql diff --git a/Sql_Solutions/Problem1.sql b/Sql_Solutions/Problem1.sql new file mode 100644 index 0000000..0a5e476 --- /dev/null +++ b/Sql_Solutions/Problem1.sql @@ -0,0 +1,3 @@ +# Write your MySQL query statement below +select name, population, area from world +where area>= 3000000 or population>= 25000000; \ No newline at end of file diff --git a/Sql_Solutions/Problem3.sql b/Sql_Solutions/Problem3.sql new file mode 100644 index 0000000..3b81c07 --- /dev/null +++ b/Sql_Solutions/Problem3.sql @@ -0,0 +1,3 @@ +# Write your MySQL query statement below +DELETE p1 from person p1 JOIN person p2 +on p1.email=p2. email and p1.id > p2.id; \ No newline at end of file diff --git a/Sql_Solutions/problem2.sql b/Sql_Solutions/problem2.sql new file mode 100644 index 0000000..96048ee --- /dev/null +++ b/Sql_Solutions/problem2.sql @@ -0,0 +1,9 @@ +CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT +BEGIN + RETURN ( + # Write your MySQL query statement below. + select DISTINCT salary from + (select salary, dense_rank() OVER (ORDER BY salary DESC) as Ranking from employee) as ranked_salary + WHERE Ranking = N + ); +END \ No newline at end of file