how can find the second max sal for every group(i.e i want
group the data based on key and find the second max sal for
every group

Answer Posted / sudipta santra

select max(sal),group_nm from
( select sal,dense_rank over (order by sal desc) rank,group_nm
from emp )
where rank=&n
group by group_nm;


Note: here &n is the bind variable which holds value from
the user, based on the requirement either 2nd max or 3rd max
or 5th max.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is bulk collect in oracle?

660


How to concatenate two text values in oracle?

691


Explain the use of owner option in exp command.

649


How do I use os authentication with weblogic jdriver for oracle and connection pools?

665


What privilege is needed for a user to query tables in another schema?

597






How to update values in a table in oracle?

660


How to run the anonymous block again?

691


What is the difference between postgresql and oracle?

593


What is proxy method?

626


What is oracle database client?

647


What is oracle rownum?

593


Can you tell me how to add new column in existing views?how?How is possible?

1020


How to experiment a data lock in oracle?

679


What is system global area (sga) in oracle?

651


What is a trigger oracle?

660