Given an employee table, how would you find out the second
highest salary?

Answer Posted / karna

select top 1 a.salary,* from emp a
where a.salary not in(select top (n-1) b.salary from emp b)

here n is the Nth values:if you want secong highest: keep n
as 2 so the query will become

select top 1 a.salary,* from emp a
where a.salary not in(select top 1 b.salary from emp b)

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

You have a table with three columns: amount1, amount2, and amount3 in a single row only one of these three columns will have a value and the other two will be null. Write a sql query to retrieve the values from these columns?

547


Hi , any one can help me on the same,this is regarding the Informatica Function doc,i want to know how developer is will develop the mapping. pl forwar the any function doc .just for my references. svlc75@yahoo.co.in

1587


What is the maximum length of an extended property?

559


Can an extended stored procedure be called from inside a user-defined function?

610


Pgm A calls Pgm B and pgm B uses cursor, when pgm B is called second time, the program is abending saying the cursor is opened? Why?

2010






Explain about normal forms?

599


Where is dbms used?

623


What is dbms explain in brief?

563


In which database can extended stored procedures be added?

530


How you can make a parameterized view?

558


What are the 18 schemas?

612


Explain about the storage and physical database design?

533


Explain the process of the user request and data generating?

653


On friday, you issued several insert statements using query analyzer. You then verified the data had been correctly entered with a select statement on monday, your users report that the data is not there what happened?

567


How to use timestamp datatypes

1578