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

Why use truncate instead of delete?

548


Why are sql stored procedures used?

617


Is ms sql traffic encrypted?

505


What is the difference between clustered and non-clustered indexes?

603


How many sql are there?

517






What is relationship? How many types of relationship are there?

592


what are the advantages of using stored procedures? : Sql dba

622


How does an execution block start and end in pl sql?

500


Which sql statement is used to delete data from a database?

467


What are different methods to trace the pl/sql code?

544


What does varchar include?

519


How to write html code in pl sql?

582


Name three sql operations that perform a sort.

592


how to create a test table in your mysql server? : Sql dba

498


What is sql query limit?

510