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 assign a table row to a record variable?
what is the syntax of UPDATE command?
what is difference between table and view? where to use views? thanks in advance!
What are the set operators union, union all, minus & intersect meant to do?
What is Network Database link ?
How many types of cluster table in Oracle?
Give SQL Query to find the number words in a sentence ? ex: 'ram charan singh' then ans:3 Answer:select length(trim('ram charan singh')) - length (replace (trim ( 'ram charan singh'),' ','')) +1 from dual The above query working properly when space between the words is only one &similar But ,If the space between the words is nonuniform. Ex:'ram charan singh is good' ans:5 i am not getting this answer using above query.
The table has 3 columns 4 rows. The output is which column has least null values( A COL SHOULD BE THE OUTPUT) Write the query plz. A B C ---------- 1 NULL 7 2 4 NULL NULL 5 NULL 3 NULL NULL
difference between oracle8i and oracle9i
what is grid in Oracle 10g...
How to apply filtering criteria at group level in oracle?
How many categories of data types?