Skip to content

Commit 49a2562

Browse files
committed
Medium
Medium Challenges
1 parent 3ecd657 commit 49a2562

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Diff for: Department Highest Salary.sql

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Select DP.Name Department, E.Name Employee, E.Salary
2+
FROM Employee E
3+
INNER JOIN (
4+
Select MAX(Salary)Salary, DepartmentId From Employee
5+
Group BY DepartmentId) D ON (E.DepartmentId = D.DepartmentId And E.Salary = D.Salary)
6+
INNER JOIN Department DP ON (E.DepartmentId = DP.Id);

Diff for: Nth Highest Salary.sql

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE FUNCTION getNthHighestSalary(@N INT) RETURNS INT AS
2+
BEGIN
3+
RETURN (
4+
/* Write your T-SQL query statement below. */
5+
select salary from (
6+
select row_number() over (order by salary desc) id, salary From(
7+
select distinct salary from employee
8+
) A
9+
) B Where Id=@N
10+
11+
);
12+
END

0 commit comments

Comments
 (0)