From c1ae5958097fb1864a557aa8af5d0ee23abf953e Mon Sep 17 00:00:00 2001 From: Shree1101 <71892807+Shree1101@users.noreply.github.com> Date: Tue, 31 Dec 2024 12:04:12 -0500 Subject: [PATCH 1/3] Create SQL1 --- SQL1 | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 SQL1 diff --git a/SQL1 b/SQL1 new file mode 100644 index 0000000..ccd5d05 --- /dev/null +++ b/SQL1 @@ -0,0 +1,7 @@ +Q1. + + +Q2. + + +Q3. From 7b97ccd4508ee35fe986292d958f0c727648c3aa Mon Sep 17 00:00:00 2001 From: Shree1101 <71892807+Shree1101@users.noreply.github.com> Date: Tue, 31 Dec 2024 12:06:43 -0500 Subject: [PATCH 2/3] SQL1 --- SQL1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SQL1 b/SQL1 index ccd5d05..51a6a4f 100644 --- a/SQL1 +++ b/SQL1 @@ -1,5 +1,10 @@ Q1. - +# Write your MySQL query statement below +select name, area, population from World +where +area >= 3000000 +or +population >= 25000000 Q2. From 4a71a3608f1265793aad2c8c56da28961cf32a91 Mon Sep 17 00:00:00 2001 From: Shree1101 <71892807+Shree1101@users.noreply.github.com> Date: Tue, 31 Dec 2024 12:35:56 -0500 Subject: [PATCH 3/3] SQL1 --- SQL1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/SQL1 b/SQL1 index 51a6a4f..42577b1 100644 --- a/SQL1 +++ b/SQL1 @@ -7,6 +7,20 @@ or population >= 25000000 Q2. - +CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT +BEGIN + RETURN ( + # Write your MySQL query statement below. + with CTE as ( + SELECT *, DENSE_RANK() + Over (Order By salary Desc) + as RNK From Employee + ) + SELECT DISTINCT IFNULL (salary, Null) + From CTE where RNK = N + + ); +END Q3. +