How to find the second largest salary in the emp database and
also How to find 3rd,4th and so on ........ in the emp database

plz mail the answer @ mak2786@gmail.com

Answer Posted / g

TO FIND THE 3rd,

select max(sal) from emptable where salary not in(select
distinct top 2 sal from emptable)

TO FIND THE 4th,

select max(sal) from emptable where salary not in(select
distinct top 3 sal from emptable)

TO FIND THE 5th,

select max(sal) from emptable where salary not in(select
distinct top 4 sal from emptable)

keep change top value...

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How you can get a list of all the table constraints in a database?

684


Explain acid?

800


Explain about integration services of Microsoft SQL server?

780


What are database states in ms sql server?

836


Explain the creation and execution of a user-defined function in the sql server?

781






Describe in brief system database.

741


Is it possible to have clustered index on separate drive from original table location?

690


What is side by side migration in sql server?

750


What are the steps to take to improve performance of a poor performing query? : sql server database administration

788


How can you know if the row fetched from cursor is still valid in underlying table?

762


How can you fetch alternate records from a table?

710


What is the purpose of a table?

731


What is "scheduled jobs" or "scheduled tasks"?

725


What is lookup override?

770


Can you always create a cache of a report?

145