Problem Statement

Write SQL queries using window functions for: employees(id, name, department, salary) 1. Find the top 2 highest-paid employees in each department 2. Rank all employees by salary within their department (show rank) 3. Find the Nth highest salary overall (use N=3)

Sample Data

employees:
(1,'Alice','Engineering',95000), (2,'Bob','Engineering',90000),
(3,'Carol','Engineering',85000), (4,'Dave','Marketing',80000),
(5,'Eve','Marketing',75000), (6,'Frank','HR',70000)

Expected Output

Q1: Alice(95k), Bob(90k) from Eng; Dave(80k), Eve(75k) from Marketing; Frank(70k) from HR
Q2: All employees with rank 1,2,3 within their dept
Q3: 3rd highest = 85000

Your Submission

ℹ️ The AI reads and reviews your code — it does not run it. Runtime errors like missing files or wrong paths won't affect your score. Focus on writing clean, correct logic.
Submit your work — choose one or more options
OR
OR