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 get second highest sal of emp table

Answer Posted / prabhudatta barick

--IN ORDER TO FIND THE NTH HIGHEST SALARY,
--WE JUST FIND THE SALARY THAT HAS EXACTLY N-1 SALARIES
GREATER THAN ITSELF---

--This is correlated subquery--
select empno,
ename,
sal
from scott.emp e
where &n-1=(select count(distinct b.sal) from scott.emp b
where b.sal>e.sal);

To get second highest salary put n value 2.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the various types of snapshots ?

1038


How i can handle exception in large code like 1000 line without distrubing the code or without exception handler sction?

3211


How to use values from other tables in update statements using oracle?

1088


What is the simplest tool to run commands on oracle servers?

1018


What is a Garbage Collection? and what is full recursive Garbage collection?

2913


What would you do with an in-doubt distributed transaction?

1992


How to convert dates to characters in oracle?

1051


Is it possible to insert comments into sql statements return in the data model editor ?

2575


What is a snapshot log?

1010


What is sharded cluster?

1021


how the Oracle Prepares the Execution Plan and how it chooses the Optimal one?

2363


What are the advantages of oracle 12c?

1187


What is the difference between "as" and "is" in an oracle stored procedure?

1006


Explain what are the different type of segments?

976


what is meant by magic query

2193