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

Answer Posted / saravanan

The below 2 queries will work
n - The nth highest salary

First query
------------------------
SELECT MAX(salary)
FROM
(SELECT salary
FROM emp
WHERE salary IS NOT NULL
ORDER BY salary DESC)
WHERE rownum < &n;

Second query
------------------------
SELECT DISTINCT(a.salary)
FROM emp a
WHERE &n =
(SELECT COUNT(DISTINCT(b.salary))
FROM emp b
WHERE a.salary <= b.salary)
;

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about merge replications?

1078


Explain indexes disadvantages?

1141


How to connect ms access to sql servers through odbc?

1069


How do we upgrade from SQL Server 6.5 to 7.0 and 7.0 to 2000?

2051


What extended events?

1062


What are the disadvantages of using querystrings to send data from one page to another?

1071


How to insert multiple rows with one insert statement in ms sql server?

1180


What is dirty page?

1035


Explain Capacity planning to create a database? and how to monitor it?

4243


What is read committed?

1169


how can u get last observation in an unknown dataset ?

2486


What is the difference between primary key and unique constraints?

1010


What are the components of dbms?

995


how to take backup bcp out for a column in table in sql server?

2144


Can you please explain the difference between function and stored procedure?

1046