Hi
What do mean by 3rd Employee Salary
if the Employee table is something like this
Employee Table
EmployeeName Salary
ABC 5000
XYZ 5000
PQR 4000
DOT 4000
NET 3000
HELLO 2000
If 3rd Employee Salary means
1. Salary of the Employee who is at stored at postion 3
--- Please note I am not showing EmployeeID of Employee
Select Salary from
(SELECT *,ROW_NUMBER() Over(order by EmpoyeeID) as Position from Employee) as X
Where X.Position=3
2. If it refers to find out the 3rd Highest Salary
You use DENSE_RANK() function or Group By clause with co related sub query to find them out
1. Using Built In Function
Select Salary from
(Select *,DENSE_RANK() Over( order by Salary desc) as SRANK from Employee) as X
where X.SRANK=3
2. Using GroupBy Clause
Select Salary from ( Select EX.* ,
(Select Count(1)+1 from
(Select Salary from Employee E group by E.Salary having E.Salary > EX.Salary) K) SRANK
from Employee EX ) X Where X.SRANK=3
Venu510, if this helps please login to Mark As Answer. | Alert Moderator