Find 2nd Highest salery in emp table

Select* from emp where &n=
select * count from emp where (salery >=emp.salery)


Enter n value 2


These query is correct or not. Tell me any other methods.

Answer Posted / ramu

by using sub quries we can do
select * from emp where sal=select max(sal) from emp where
sal<select max(sal) from emp;

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a full text index?

492


What are actions, how many types of actions are there, explain with example? : sql server analysis services, ssas

540


What is the use of builtinadministrators group in sql server? : sql server security

526


Which sql server table is used to hold the stored procedure script?

475


How to compare the top two records using sql?

761






What is a matrix in ssrs?

101


How to create function without parameter in sql server?

557


Is the order of columns in the set clause important in ms sql server?

518


Explain what is log shipping?

574


What is the difference between count () and rowcount ()?

518


We need to perform what steps in the following order to work with a cursor?

709


What is the difference between substr and charindex in the sql server?

506


What are the High-Availability solutions in SQL Server and differentiate them briefly?

697


What are cursors stored procedures and triggers?

512


What is cursors?

636