Find 5th Highest salary in LinQ , SQL server, write code in C# 2.0. Is there any inbuilt function in C# which can give us direct output as Highest 5th Salary.?
Vivek Sheth
Select*from (Select EmpId,EmpName,salary,row_number() over(order by salary desc) rowno from Tbl_SalaryProcess)Q1 where Q1.rowno=5
select top 1 sal from (select top 5 sal from emp order by sal desc) e order by sal asc
Check this link : http://www.c-sharpcorner.com/blogs/experiment-with-nth-highest-or-lowest-salary-or-record-in-sql
SELECT TOP(1) EMPNAME,MAX(SALARY) SALARY FROM tblname GROUP BY EMPNAME ORDER BY salary DESC
??? runman7942.com ?? ???? ???? ?? ????
select top(1) Salary from ( select distinct top(5) Salary from tblEmployee order by Salary DESC )as Temp order by Salary ASC
with Cte as ( Select name,address,Dense_rank()over(partition by salary order by salary )r as rank from emp ) select top 1 * from Cte from where rank=5
DataContext context = new DataContext(); var q= context.tblEmployee.GroupBy(ord => ord.Salary) .OrderByDescending(f => f.Key) .Skip(4) .First() .Select(ord=>ord.Salary) .Distinct();