To find second largest salary in Employee table

Answer Posted / ram

select *from emp e where &n in(select count(distinct sal)
from emp m where e.sal<=m.sal);

which will ask's u like :

enter the value for n : 2 (enter 2)
gives u second highest.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between inner join and full join?

546


Can you explain different types of joins?

546


What is store procedure? When do you use?

523


Does a sql server 2005 select statement require a from?

578


How many clustered indexes there can be on table ?

598






What is recompile sql server?

565


What is data modeling and Reterminal integrity?

1490


What is a bit datatype?

560


How will you hide an attribute? : sql server analysis services, ssas

519


What does the on delete cascade option do?

548


How optimize sql query with multiple joins in sql server?

413


What is multi-statement table-value user-defined function?

534


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

613


What is deploy, process and build? : sql server analysis services, ssas

568


What happens if ntwdblib.dll is missing on your machine?

632