how to calcuate the second highest salary of he employee

Answer Posted / jitendra

To get nth highest Salary, use below query

SELECT TOP 1 salary
FROM (
SELECT TOP nth salary
FROM Emp
ORDER BY salary DESC
) TmpTable
ORDER BY salary ASC

Replace nth with your number like second highest=2 4th=4 etc

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can we avoid duplicating records in a query?

565


What is sql partition?

552


Where not exists in sql?

503


Does mysql_real_escape_string prevent sql injection?

539


How do you copy a table in sql?

563






Which column in the user.triggers data dictionary view shows that the trigger is a pl/sql trigger?

603


How do you write a complex sql query?

589


Why commit is not used in triggers?

583


Can I learn sql in a week?

554


What is normalization sql?

513


Explain the structure of pl/sql in brief.

621


What is normalisation in sql?

553


What are different clauses used in sql?

588


What is schema in sql?

518


How do I view output in sql developer?

578