How To Find Highest Paid Salary using Sql Server

Jayakumars
Posted by Jayakumars under Sql Server category on | Points: 40 | Views : 874
Hi

Some Simple Sql Query Find Highest Salary Using Row_Number

--First Highest Salary
Select MAX(salary)FROM Employee

--Second Highest Salary
Select MAX(salary)FROM Employee where Salary
<(Select MAX(salary)FROM Employee)

--Third Highest Salary
Select MAX(salary)FROM Employee where Salary
<(Select MAX(salary)FROM Employee where Salary<(Select max(salary)FROM Employee))


-- Highest Salary Another Way First Only
;with emp as
(
SELECT ROW_NUMBER()OVER(ORDER BY Salary DESC)as Id,* from Employee
)Select * from Emp where ID=1

-- Highest Salary Another Way Ranges
;with emp as
(
SELECT ROW_NUMBER()OVER(ORDER BY Salary DESC)as Id,* from Employee
)Select * from Emp where ID in (1,4)

Comments or Responses

Login to post response