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

column A column b | output 10 7 | 10 5 8 | 8 7 -9 | 7 3 5 | 5 0 6 | 6 Write a sql query to print such output.

6053


Define implicit and explicit cursors.

622


Is postgresql a nosql database?

525


What is the unique index?

520


What does pl sql developer do?

504






What is the difference between between and in condition operators?

528


Advantages and disadvantages of stored procedure?

573


How to revise and re-run the last sql command?

640


How many unique keys can a table have?

545


Can you select everything, but 1 or 2 fields, without writer's cramp?

491


What is java sql package?

525


explain commit and rollback in mysql : sql dba

537


How many triggers can be applied on a table?

501


What are the key differences between SQL and PL SQL?

621


Which is faster subquery or join?

649