how to calcuate the second highest salary of he employee

Answer Posted / ramya p

SELECT DISTINCT (sal),deptno FROM emp a
WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM emp b
WHERE a.sal<=b.sal)

N is the Nth highest salary you want to print. In this case
N=2

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of primary key?

523


What is clause?

602


What is sql partition function?

608


Write a query to find the names of users that begin with "um" in sql?

490


Is the primary key an index?

588






Difference between global and parameter variables?

1448


Can we create clustered index without primary key?

517


How can you maintain the integrity of your database on instances where deleting an element in a table result in the deletion of the element(s) within another table?

659


Mention what are the benefits of pl/sql packages?

531


Can we create table inside stored procedure?

525


How do I partition a table in sql?

531


What are the qualities of 2nf?

536


Is sql a scripting language?

509


Why do we need unique key in a table?

517


What are the syntax and use of the coalesce function?

545