adspace


can anybody tell us, how to select 2nd max salary from
table.
my id is ashish.akk@gmail.com

Answer Posted / syaam

select a.sal from emp a
where 2=(select count(distinct b.sal) from emp b
where a.sal<= b.sal)


for getting nth max sal ..replace 2 by n


all the best

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there any performance difference between if exists (select null from table) and if exists (select 1 from table)?

1024


Can one drop a column from a table?

1091


How can we solve concurrency problems?

1123


explain different types of backups avaialabe in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration

1134


How do I find query history in sql server?

1026


Why and when do stored procedure recompile?

1064


Explain “row_number()” in sql server with an example?

1080


do you know how to configure db2 side of the application? : Sql server database administration

1125


How do I create a trace in sql server?

1121


What is normalization and what are the advantages of it?

1057


When should you use an instead of trigger?

1054


Is it possible to have clustered index on separate drive from original table location?

1041


How to provide default values to function parameters?

1261


List the ways in which dynamic sql can be executed?

1088


Explain system functions or built-in functions? What are different types of system functions?

1067