javatechie

Find Nth Highest Salary

Sep 23rd, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.21 KB | None | 0 0
  1. //approach: 1
  2. SELECT salary FROM Employee e1 WHERE N-1=(SELECT DISTINCT COUNT(salary) FROM Employee e2 WHERE e2.salary>e1.salary);
  3.  
  4. ////approach: 2
  5. SELECT salary FROM Employee ORDER BY DESC salary LIMIT N-1, 1
Add Comment
Please, Sign In to add comment