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 |
what is a cartition product?
Can we create database in oracle using command line ?
What are the sql clauses supported in the link property sheet ?
What is an Oracle index?
What is an UTL_FILE.What are different procedures and functions associated with it?
Explain the difference between a procedure and a function? What do you understand by those terms?
What is a nvl function? How can it be used?
How to display employee records who gets more salary than the average salary in the department?
How to view the tablespaces in the current database?
What is blob datatype?
diff between DELETE and TRUNCATE?.
14 Answers HCL, Yalamanchili Software,
What language does oracle use?