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
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 |
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 |
What is an oracle user role?
How to select some columns from a table in oracle?
how to find count rows in table without count function?
select * from emp what happened internally when we write this query in the sql prompt?
What spfile/init.ora file parameter exists to force the CBO to make the execution path of a given statement use an index, even if the index scan may appear to be calculated as more costly?
Is oracle a language?
What is a package ? What are the advantages of package ?
Which environment variables are absolutely critical in order to run the OUI?
Point the difference between translate and replace?
How to create a new table by selecting rows from another table?
What are the different types of modules in oracle forms?
What is the best way to do multi-row insert in oracle?