how to get the second max val for every group in a table
Answers were Sorted based on User's Feedback
Answer / venkat
select * from (
select e.deptno,d.dname,e.sal,dense_rank() over (
partition by e.deptno
order by e.sal desc ) "RANK",
e.ename
from emp_test e,dept_test d
where e.deptno=d.deptno)
where rank=2
| Is This Answer Correct ? | 9 Yes | 5 No |
Answer / suman rana
--venkat u r almost correct, since u have used "" (double
quotes) so column name will be come case sensitive.
select * from (
select e.deptno,d.dname,e.sal,dense_rank() over (
partition by e.deptno
order by e.sal desc ) RANK, e.ename
from emp_test e,dept_test d where e.deptno=d.deptno)
where rank=2
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / suman rana
select * from emp e where 2 = ( select count(distinct sal)
from emp e1 where e1.deptno = e.deptno and E.SAL <= E1.SAL)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ram posam
select * from (select deptno,sal,rank() over(partition by
deptno order by sal desc) k
from emp
group by deptno,sal)
where k=&n;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / indu
select max(sal) from salary where sal NOT IN (select max(sal) from salary)
| Is This Answer Correct ? | 9 Yes | 13 No |
How to loop through data rows in the implicit cursor?
What are the uses of Rollback Segment ?
How do we display rows from the table without duplicates?
What is oracle used for?
I have a table called 'test' on source and target with same name, structure and data type but in a different column order. How can you setup replication for this table?
Other than making use of the statspack utility, what would you check when you are monitoring or running a health check on an Oracle 8i or 9i database?
How to use "for" statements in oracle?
19. Display all clients whose name begins with the letter J or contains the letter M anywhere or contains E as the third letter.
Explain the importance of .pll extension in oracle?
10)In an RDBMS, the information content of a table does not depend on the order of the rows and columns. Is this statement Correct? A)Yes B)No C)Depends on the data being stored D)Only for 2-dimensional tables
What is an Index Segment ?
How do you store pictures in a database?