Can you get second highest salary from the table?



Can you get second highest salary from the table?..

Answer / Vijay Jha

{"Yes, to retrieve the second highest salary from a table in SQL Server, you can use a combination of subqueries or window functions such as DENSE_RANK() function. Here's an example using DENSE_RANK():"
`SELECT TOP 1 salary FROM employees WHERE salary = ( SELECT TOP 1 DISTINCT MAX(salary) FROM employees WHERE salary < ( SELECT MAX(salary) FROM employees ) );`"

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What is an Index?

3 Answers   Yardi Software,


What Is Rdbms?

1 Answers   Accenture,


What would be the Expected Salary For SQL Server Developer for 3 years exp. as per indian market?

7 Answers  


What you can do to delete a table without the delete trigger firing?

1 Answers  


Please explain what is “asynchronous” communication in sql server service broker?

1 Answers  


explain what is a deadlock and what is a live lock? How will you go about resolving deadlocks? : Sql server database administration

1 Answers  


What is blocking in SQL Server? If this situation occurs how to troubleshoot this issue

2 Answers   IBM,


What is failover clustering overview?

1 Answers  


hi i am working as a testengineer , so i want to no the backend data base connection can any one tell mwe in detail

1 Answers   IntraLogic, Oracle,


Do you know what are the ways available in sql server to execute sql statements?

1 Answers  


how many instance use in sql server 2005

4 Answers   EFI, HCL,


Explain encryption of entire databases without the need for application changes in sql server 2008?

1 Answers  


Categories