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 to do if the binary spfile is wrong for the default instance?

566


What are the attributes of cursor?

592


State the various uses of dbcc command?

551


What is connection pooling in oracle?

552


What are the various constraints used in oracle?

556






How many types of database triggers exist?

578


How to define a sub function?

671


What happens if you set the sga too low in oracle?

559


How to define an anonymous procedure with variables?

547


how to clone 9i Database on to 10g Database.

1829


If any one has information regarding interview of NIC (National Informatics Centre),it would be of great help...

1741


master table and child table performances and comparisons in Oracle ?

1668


What are joins, explain all types of joins?

1724


What is dynamic proxy?

554


Difference between varchar and varchar2 data types?

668