Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to find nth highest salary

Answers were Sorted based on User's Feedback



how to find nth highest salary..

Answer / sameera chiluka

select secondMAXsal from emp
WHERE seconMAXsal = ((MAXsal)-1);

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / amarjit singh

--display 3rd higest salary in MSSQLSERVER
select max(sal) from emp
where sal <(select max(sal) from emp
where sal <(select max(sal) from emp
))

--By , STUDENT OF IET BHADDAL ENG COLLEGE

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / balindra sahani

select max(salary) from table_name where max(salary)not
in(select top(n) from table_name order by salary asc)

where n=nth number salary

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / mangalesh porwal

HERE N IS THE NO WHICH HIGHEST NO U WANT..........
IT SURELY WORKS.....

SELECT TOP 1 * FROM (SELECT TOP N * FROM (SELECT ROLLNO FROM TABLE_NM ) AS D ORDER BY ROLLNO DESC) AS P ORDER BY ROLLNO

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / p rem satyam

This is perfect
...............................

select * from emp e1 where (N-1)=( select
count(distinct(e2.sal) from emp e2 where e2.sal > e1.sal)

where N is level of sal. suppose you want 3rd higest sal then
in place u write 3 i.e write (3-1).

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / venuprasadh

SELECT MIN(SALARY) AS Salary FROM user WHERE SALARY IN
(SELECT DISTINCT TOP 3 SALARY FROM user ORDER BY SALARY DESC);

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / ravikiran

select * from employee.e1 where (n-1) =
( select (distinct b.salary ) from employee.e2 where e1.salary > e2.salary

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / amit kumar

--- Getting 4th highest salary
--- 4 can be replaced with any number

with EmpSal as
(Select *, row_number() over (order by EmpSal Desc)
as 'rownumber' from employee)

Select * from EmpSal where rownumber =4

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / neeraj kumar

select top(1) salary from(
select distinct nth salary
from emp
order by salary desc)a
order by salary



In this answer you can put any position in place of nth then you find the salary.
If you are satisfied this answer then reply me please.

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / jeevan

CREATE TABLE
[dbo].[Table_1]([ID] [int] NOT NULL,[SAL] [int] NULL)

//N=9
SELECT TOP 1 * FROM dbo.Table_1
WHERE ID NOT IN (SELECT TOP 8/*N-1*/ ID FROM dbo.Table_1
ORDER BY SAL DESC)
ORDER BY SAL DESC

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What is the significance of master, tempdb and model databases?

0 Answers  


What protocol does sql server use?

0 Answers  


What are triggers? How many triggers you can have on a table? How to invoke a trigger on demand?

0 Answers  


How to create and drop temp table in sql server?

0 Answers  


What is cross join in sql server joins?

0 Answers  


how to use DTS package in 2000,2005,2008 in sql server

0 Answers   Microsoft,


what is a correlated sub-query? : Sql server database administration

0 Answers  


How to provide values to stored procedure parameters in ms sql server?

0 Answers  


What is collation sensitivity?

0 Answers  


What is difference between aggregate and analytic function?

0 Answers  


Explain boyce and codd normal form(bcnf)?

0 Answers  


Explain “not null constraint” in sql server?

0 Answers  


Categories