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

What are views in sql?

721


Which is the correct statement about truncate and delete?

757


What will you get by the cursor attribute sql%notfound?

778


Does asenumerable execute the query?

775


What is scalar and vector?

720






What is user in sql?

762


What are the query optimization techniques?

711


How do you remove duplicates without using distinct in sql?

695


What is rowtype?

767


What are joins in sql?

719


how to start mysql server? : Sql dba

864


What are the basic techniques of indexing?

781


how to use regular expression in pattern match conditions? : Sql dba

731


What is oracle pl sql developer?

706


What is case function?

778