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

How to end the current transaction in oracle?

988


What is execute immediate in oracle?

973


Can a formula column be obtained through a select statement ?

2288


How will you identify oracle database software release?

962


How to use existing values in update statements using oracle?

1032


Explain the function of optimizer in oracle?

1086


What happens to the data files if a tablespace is dropped?

1019


How to estimate disk space needed for an export job?

1011


What is BBED in Oracle?

1117


Explain integrity constraints?

1079


11. Display the client number and name and the client number and name of the person who referred that client.

2295


How can you use check constraints for self referential integrity?

934


What are advantages of dateset in datastage?

2225


how to handle exceptions in post production

1382


Which is faster join or subquery in oracle?

954