How to retrieve a second highest salary from a table?
Note:Suppose salaries are in duplicate values
eg:
Name Sal
Malli 60000
Pandi 60000
Rudra 45000
Ravi 45000

Answer Posted / praveenpinfo

Suppose table name is EMP.

SQL> Select distinct sal from emp e1 where 2=(select
count(distinct sal) from emp e2 where e1.sal<=e2.sal);

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to install mysql? : Sql dba

575


Does a primary key have to be a number?

512


What does desc stand for?

584


Which join is like an inner join?

519


What are aggregate and scalar functions?

519






Is natural join and inner join same?

485


Is left join and outer join same?

536


What is database sql?

535


How to display the current date in sql?

590


What do you understand by exception handling in pl/sql?

567


Why primary key is required?

541


How can a function retun more than one value in oracle with proper example?

574


What are different functions in sql?

506


Is delete faster than truncate?

537


what are the differences among rownum, rank and dense_rank? : Sql dba

534