From e2d5a50262ff214e3b5870f8a2137fd0cbf45229 Mon Sep 17 00:00:00 2001 From: Priyam2773 Date: Fri, 31 Oct 2025 00:00:58 +0530 Subject: [PATCH 1/3] Create function to get Nth highest salary Implement a function to retrieve the Nth highest salary from the Employee table. --- 177. Nth Highest Salary | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 177. Nth Highest Salary diff --git a/177. Nth Highest Salary b/177. Nth Highest Salary new file mode 100644 index 0000000..3ea8fe1 --- /dev/null +++ b/177. Nth Highest Salary @@ -0,0 +1,11 @@ +CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT +BEGIN +SET N = N-1; + RETURN ( + SELECT DISTINCT(salary) from Employee order by salary DESC + LIMIT 1 OFFSET N + + ); +END + +#pls upvote if you find solution easy to undestand....!! Thanks..!!! From 48eac2df6ed6d00caa648196c090551265e19671 Mon Sep 17 00:00:00 2001 From: Priyam2773 Date: Fri, 31 Oct 2025 00:12:45 +0530 Subject: [PATCH 2/3] Add SQL query for second highest salary --- 176. Second Highest Salary | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 176. Second Highest Salary diff --git a/176. Second Highest Salary b/176. Second Highest Salary new file mode 100644 index 0000000..672b2ac --- /dev/null +++ b/176. Second Highest Salary @@ -0,0 +1,6 @@ +SELECT ( + SELECT DISTINCT salary + FROM Employee + ORDER BY salary DESC + LIMIT 1 OFFSET 1 +) AS SecondHighestSalary; From 56251bae4e02c766753ce46ee7981c09bec4fa58 Mon Sep 17 00:00:00 2001 From: Priyam2773 Date: Fri, 31 Oct 2025 00:19:24 +0530 Subject: [PATCH 3/3] Add query to find employees earning more than managers --- 181. Employees Earning More Than Their Managers | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 181. Employees Earning More Than Their Managers diff --git a/181. Employees Earning More Than Their Managers b/181. Employees Earning More Than Their Managers new file mode 100644 index 0000000..7b8a6be --- /dev/null +++ b/181. Employees Earning More Than Their Managers @@ -0,0 +1,4 @@ +SELECT e1.name AS Employee +FROM Employee e1 +JOIN Employee e2 ON e1.managerId = e2.id +WHERE e1.salary > e2.salary;