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

How to test a dml trigger in ms sql server?

756


Tell me about joins in database system and explain each in detail.

802


what is a live lock? : Sql server database administration

636


What are the new features introduced in SQL Server 2000 (or the latest release of SQL Server at the time of your interview)? What changed between the previous version of SQL Server and the current version?

806


What is a transact-sql statement?

709






What will happen if a column containing char type data is changed to the nchar data type?

799


Find first and last day of current month in sql server

766


Can you tell me some of the common replication dmv's and their use? : sql server replication

714


When we should use and scope of @@identity?

721


What are the steps to follow to configure SQL*Net?

774


What are the system database in sql server 2005?

734


what is a schema in sql server 2005? Explain how to create a new schema in a database? : Sql server database administration

722


What are trace files?

707


What are the limitations/drawbacks or ssrs 2008 r2?

105


can an order by clause be used in a creation of a view?

883