blog post

-- Start to find second highest salary of Emaploye-----

Method No.1

 select name,Salary from tab_employees e1 where 1=(select COUNT (id) from tab_employees e2 where e2.salary>e1.salary) 

Method No.2

 select * from ( select name,Salary, ROW_NUMBER() OVER(order by salary desc) as rownum from tab_employees ) e where e.rownum=2 

Method No.3

select top 1 name,Salary from tab_employees e where salary not in (select top 1 salary from tab_employees order by salary desc) order by salary desc 
-- End to find second highest salary of Emaploye-----

  • Share This Story

Pleas give your valuable comments to improve the contents.

Leave a comment


Get More Stuff
Subscribing to the TheOneblogs newsletter and get intersting stuff and updates to your email inbox.
Your Email


Style Switcher

Change Color

×! We use cookies to improve your user experience. More information