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

Explain compound trigger in oracle?

1091


How to export several tables together?

1112


What is the maximum limit on the number of columns in a table?

1170


Explain oracle insert into command?

1165


Calculate difference between 2 date / times in oracle sql?

1103


Is oracle the best database?

1015


Why do you create or replace procedures rather that drop and recreate.

1078


What is a cognitive schema?

1038


What is an oracle tablespace?

1098


How to create an initialization parameter file?

1116


What are the various oracle database objects?

1206


How to define a variable to match a table column data type?

1044


What is SQL access advisor in Oracle?

1240


What is a sub query and what are the different types of subqueries?

1183


What is the difference between I and G in Oracle?

1162