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 / dewesh

With cte as (
Select *, Dense_rank() over (order by salary desc) as s from emp)
Select EmpName, Salary from cte where s =2
It has work. But duplicate value is not removed if name is different

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you create a unique index?

573


What is linq to sql?

552


What is %type in pl sql?

540


What is spool?

592


What is the difference between the implicit and explicit cursors?

525






How does cross join work?

504


Can we write ddl statements in functions?

567


What are the ways on commenting in a pl/sql code?

511


Which is faster subquery or join?

660


What packages(if any) has oracle provided for use by developers?

5031


Name three sql operations that perform a sort.

588


what is oracle database ? : Sql dba

557


what is a view? : Sql dba

636


What is embedded sql with example?

544


Explain ttitle and btitle.

670