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