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 / prasant palo

with ttble as
(
select top 3 empid,empname,empsalary
from
emptable
order by empsalary desc
)
-- above will create a common table expression with name
--ttable
-- to know about it search for commontable expression
select top 1 empid,empname,empsalary
from
ttable
order by empsalary asc

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Due to some maintenance being done, the sql server on a failover cluster needs to be brought down. How do you bring the sql server down?

884


Does sql server use java?

526


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

540


What new data source types were added in ssrs 2014?

109


What is the difference between the export /import functions in sql studio and standalone sql manager? : sql server management studio

599






Does an index slow down updates on indexed columns?

590


What are user-defined functions (udfs) in sql server?

580


When is update_statistics command used?

598


What is stored in the mssqlsystemresource database? : sql server database administration

602


What is the process of normalising?

604


How can we remove orphan records from a table?

544


How to create nested stored procedure?

550


Can we join two tables without primary key?

624


Why and when do stored procedure recompile?

555


explain the storage models of olap? : Sql server database administration

529