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...


find out the third highest salary?

Answers were Sorted based on User's Feedback



find out the third highest salary?..

Answer / rajdevar

Guys
i have executed this query in sql plus.This is correct

Select * from EMP_USER A where n-1 = (select count
(distinct (sal)) from EMP_USER B where A.sal<B.sal)

where n=3

reason for using n-1 is below:

1.We are using correlated sub query.so sal value from each
row in outer query(EMP_USER A) is compared with sal of all
the rows in EMP_USER B

eg:
ENAME SAL
----- -----
SMITH 800
KING 5000
FORD 3000

here third highest is 800.so when executing this 800 from
outer query is compared with 800,5000,3000 in inner query
which returns a count(distinct(sal) = 2

if you use n instead of n-1 you get a empty result.

Let me know if this is correct

Is This Answer Correct ?    13 Yes 5 No

find out the third highest salary?..

Answer / vishal

Here is the correct query:

select ename,sal from emp e
where 3 = (select count(distinct(sal))+1 from emp
where e.sal < sal);

Is This Answer Correct ?    12 Yes 5 No

find out the third highest salary?..

Answer / sudheer

Guys Few of you have submitted an optimal query.

select distinct sal from emp A where 3 = (select count(sal)
from emp B where a.sal > b.sal)

However the integer 3 will not give the third highest salary
as expected. Point should be noted that the row starts with
zero.

so the actual result will the fourth highest salary with the
above query.

Is This Answer Correct ?    7 Yes 3 No

find out the third highest salary?..

Answer / manoj

select salary from emp
where salary = (select max (salary) from emp
where salary < (select max (salary) from emp
where salary < (select max (salary) from emp)));

Is This Answer Correct ?    5 Yes 1 No

find out the third highest salary?..

Answer / kss

Hi every one,

i know that we can get that thr above quer..

one can try using analytic function giving ranks to the
salary column

select sal,dense_rank() over(order by sal desc) rank from
emp

Is This Answer Correct ?    18 Yes 15 No

find out the third highest salary?..

Answer / nehal

select e.sal from employee where n-1=(Select count(distinct
sal) from emp where sal>e.sal)


Put n=3 for the 3rd highest salary.

Is This Answer Correct ?    10 Yes 7 No

find out the third highest salary?..

Answer / selvaraj anna university coe

In Oracle 9i:
-------------

SQL> SELECT MAX(salary) FROM emp WHERE LEVEL=&no CONNECT BY
PRIOR Salary>salary;


Enter value for no: 3

old 1: SELECT MAX(SALARY) FROM EMP WHERE LEVEL=&no
CONNECT BY PRIOR SALARY>SALARY
new 1: SELECT MAX(SALARY) FROM EMP WHERE LEVEL=3 CONNECT
BY PRIOR SALARY>SALARY

MAX(SALARY)
-----------
500000

SQL>

Is This Answer Correct ?    8 Yes 5 No

find out the third highest salary?..

Answer / saleem

select distinct(a.sal) from emp a where &3 = ( select count
(distinct(b.sal) from emp b where a.sal <= b.sal));

Is This Answer Correct ?    8 Yes 6 No

find out the third highest salary?..

Answer / chanchal

SELECT MIN(salary) FROM Department WHERE salary IN
(SELECT TOP 3 salary FROM Department ORDER BY salary DESC)

Is This Answer Correct ?    4 Yes 2 No

find out the third highest salary?..

Answer / raj

Answer 28 is the dumbest way of writing the query.what
would you write if i want the 25 highest salary? repeat
this satement 25 times.

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More Oracle General Interview Questions

What is a Segment ?

1 Answers  


How do I manually uninstall oracle client?

0 Answers  


find out the third highest salary?

92 Answers   CIPL, Cyber Shot, HCL, Hewitt, IBM, JPMorgan Chase, Orion, Verizon,


What is the scope of a local variable?

0 Answers  


How can you use check constraints for self referential integrity?

0 Answers  


how to i write the query 'NISHI' TO N I S H I

4 Answers   Attra, Metric Stream,


what are corelated subqueries

1 Answers   Global Infotech,


How to assign a table row to a record variable?

0 Answers  


17. Display the order number and average item cost for each order.

1 Answers   Wipro,


How to drop an index?

0 Answers  


How to set a transaction to be read only in oracle?

0 Answers  


How to Select second Maximum salary in a Table ?

13 Answers   Oracle,


Categories
  • Oracle General Interview Questions Oracle General (1803)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)