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 / ganesh prasad

all are not working properly incase repeat salary
this one is correct to finding 4th highest salary try run
your system then call me 9438183722

select min(deptsal) from dept where deptsal in ( select
distinct top 4 deptsal from dept order by deptsal desc)

Is This Answer Correct ?    5 Yes 14 No

how to find nth highest salary..

Answer / sysdomain

'top' will fetch only top most : ie top 5 means it will
fetch first 5 rec. After fetching rec only 'order by' is
done ie sorting is done after fetching. therefore using
'top' and 'order by' alone wont get max or min value. for
that we have to use 'distinct' before 'top' (which will sort
the records before fetching).

select top 1 salary from employee where salary in (select
distinct
top n salary from employee order by salary desc)

Is This Answer Correct ?    7 Yes 16 No

how to find nth highest salary..

Answer / saurabh

select max(salary) from Employee where salary not in (
select top 5 Salary from ( select distinct Salary from
Employee order by Salary desc))

Is This Answer Correct ?    0 Yes 11 No

how to find nth highest salary..

Answer / vijay dev arya

select salary from employee where salary>(select max
(salary) from employee)

Is This Answer Correct ?    6 Yes 17 No

how to find nth highest salary..

Answer / smitam

select top 1 salary from emp where (salary<(select max
(salary) from emp ))ORDER BY salary DESC

Is This Answer Correct ?    9 Yes 21 No

how to find nth highest salary..

Answer / vijay

select top 1 sal
from
(select top 3 sal
from emp
order by sal desc )sub
order by sal

Is This Answer Correct ?    12 Yes 24 No

how to find nth highest salary..

Answer / suhail qaiser

SELECT TOP Nth salary
FROM (
SELECT TOP N salary
FROM emp
ORDER BY salary DESC
) TmpTable
ORDER BY salary ASC

Is This Answer Correct ?    38 Yes 56 No

how to find nth highest salary..

Answer / pandian

select top 1 salary from (select distinct top 9 salary from
EmpMaster order by salary desc)a

Is This Answer Correct ?    65 Yes 88 No

how to find nth highest salary..

Answer / kavitha. r

select top 1 salary from employee where salary in (select
top n salary from employee order by salary desc) order by
salary desc

Is This Answer Correct ?    12 Yes 40 No

how to find nth highest salary..

Answer / mayur

DECLARE @SQL VARCHAR(2000), @N INT
SET @N = 5
SET @N = @N - 1

SET @sql = 'select top 1 salary from ABC where salary not
in ( SELECT TOP ' + CAST(@n AS VARCHAR(100)) + ' salary
FROM ABC ) '

SELECT @SQL

EXEC (@SQL)

Is This Answer Correct ?    24 Yes 71 No

Post New Answer

More SQL Server Interview Questions

Explain SELF JOIN ?

3 Answers   ADP,


What is the difference between the following two sql statements select count(*) from <tablename> select count(col_name) from <tablename>

5 Answers   247Customer,


if you encounter this kind of an error message, what you need to look into to solve this problem? : Sql server database administration

0 Answers  


Describe in brief databases and sql server databases architecture.

0 Answers  


What is transact-sql ddl trigger?

0 Answers  


How can I create a plain-text flat file from SQL Server as input to another application?

2 Answers  


How to get a list of table columns using the "sp_columns" stored procedure in ms sql server?

0 Answers  


Explain cdc and sql injection?

0 Answers  


What is the order in which the SQL query is executed? list them in order.

5 Answers   CarrizalSoft Technologies, CTS, Oracle,


Differentiate between ms sql server reporting services vs crystal reports?

0 Answers  


How to select some specific columns from a table in a query in ms sql server?

0 Answers  


plz tell me the new features of sqlserver2000,sqlserver2002,sqlserver2005

3 Answers  


Categories