Advertisement
yuvarajupadhyaya

Second highest salary

May 28th, 2022
2,417
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT top 1 emp_salary FROM (SELECT top 2 emp_salary FROM EmployeeInfo ORDER BY emp_salary DESC) a ORDER BY emp_salary ASC
  2.  
  3. SELECT  MAX(emp_salary) FROM EmployeeInfo WHERE emp_salary <   (SELECT MAX(emp_salary) FROM EmployeeInfo)
  4.  
  5. SELECT emp_salary FROM ( SELECT emp_salary,
  6. ranking=DENSE_RANK() OVER(ORDER BY emp_salary DESC)
  7. FROM EmployeeInfo) a WHERE a.ranking=2
  8.  
Advertisement
RAW Paste Data Copied
Advertisement