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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / nathan

SELECT *
FROM (SELECT deptno, sal,
DENSE_RANK () OVER (PARTITION BY deptno ORDER
BY sal DESC)

ranks
FROM emp)
WHERE ranks = 2;

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More Oracle General Interview Questions

Is a rollback possible to any savepoint?

0 Answers  


What different of iner joint & outer joint with example

4 Answers  


What is raw datatype?

0 Answers  


Is it possible to disable the parameter from while running the report ?

1 Answers   Honeywell, Oracle,


How to unlock the sample user account in oracle?

0 Answers  






What privilege is needed for a user to create indexes in oracle?

0 Answers  


What is cluster Key ?

3 Answers  


What is an oracle database?

0 Answers  


Explain the use of grant option in imp command.

0 Answers  


what is the output of select * from emp where null=null & select * from emp where 1=1

8 Answers   IMS Health, NIIT,


What is parameterized cursor in oracle?

0 Answers  


What is control file used for?

0 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)