Write a query to find second highest salary of an employee.

Answer Posted / prashant srivastava

**Exact answer to the question**

SELECT MIN(e1.Salary) FROM emp e1 WHERE e1.Salary IN
(Select e2.Salary from emp e2 ORDER BY e2.Salary DESC FETCH
FIRST 2 ROWS ONLY)

**Generic Solution**

SELECT MIN(e1.Salary) FROM emp e1 WHERE e1.Salary IN
(Select e2.Salary from emp e2 ORDER BY e2.Salary DESC FETCH
FIRST n ROWS ONLY)

Just replace n as the asked rank of the salary. For instance

If 29th highest salary is asked then replace n with 29..
simple...isn't it? :):)

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell me which web driver implementation is the fastest?

525


Give some examples for test management tools?

587


How do you identify the test cases which are suitable for automation?

563


Define sdlc in testing.

588


hi every one this is ashok pls any one give answer me pls question is while testing with selenium after giving id user name and password , the inbox will be open , how to handle this one

1598






How will you automate basic “login” functionality test cases for an application?

543


What criteria do you consider for automating a test?

550


List the five essential types of test steps?

570


What is build verification testing, bvt?

623


Tell me what kind of tests should not be automated?

530


What is meant by the automation framework?

546


Kindly let me know how to setup JMeter for functionality testing of a Web application.. The apache help doc is good but i m little confused with it... :(

1775


Can any one give me the script for drag and drop or setselection functions ?like in a not pad i want to select 5 lines

1442


Tell me how can we find the value of different attributes like name, class, value of an element?

596


What are the advantages of the automation framework?

536