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

what are the types of subquery? : Sql dba

768


What is the process of copying data from table a to table b?

803


Can sql function call stored procedure?

739


Explain some predefined exceptions.

778


How do you break a loop in pl sql?

730






Does a join table need a primary key?

708


Are left and right joins the same?

720


Which table is left in left join?

716


how to return query output in html format? : Sql dba

850


What is before and after trigger?

691


What is using in sql?

795


Are views faster than queries?

726


Explain ttitle and btitle.

840


What does count (*) mean in sql?

1291


What sql database should I use?

787