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 / prashant narvekar

1. solution taken as std_id instead of salary
select max( b.std_id) from std_info a
inner join std_info b on a.std_id <> b.std_id
where a.std_id > b.std_id

2. solution
select max(std_id) from std_info
where std_id < ( select max(std_id) from std_info)

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what stored procedure would you use to view lock information? : Sql server administration

589


what is sql server? : Sql server database administration

546


What is a subquery in a select query statement in ms sql server?

593


What is impersonation? What are the different impersonation options available in ssas? : sql server analysis services, ssas

556


How much space does sql server 2016 take?

571






What is hierarchy, what are its types and difference between them? : sql server analysis services, ssas

704


What is the contrast between sql and mysql?

598


What to perform pattern match with the like operator?

492


What are examples of triggers?

624


Can we use pragma autonomous_transaction in trigger?

550


Does dbcc checkdb requires db to be in single_user mode? : sql server database administration

526


What will be query used to get the list of triggers in a database?

555


Can we return Data from 4(more than 1) tables in stored procedure?

624


Tell me the use of keyword with encryption. Create a store procedure with encryption?

561


Define constraints and give an example of their use?

567