Answer Posted / divakarreddy
SQL> select *from (select ename,sal,deptno,rank()
2 over(partition by deptno order by sal desc)topsal
3 from emp)
4 where topsal<=3
5 order by deptno,sal desc;
ENAME SAL DEPTNO TOPSAL
---------- ---------- ---------- ----------
KING 5000 10 1
MILLER 3000 10 2
CLARK 2450 10 3
SCOTT 3000 20 1
JONES 2975 20 2
ADAMS 1100 20 3
BLAKE 2850 30 1
ALLEN 1600 30 2
TURNER 1500 30 3
9 rows selected.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why do we use procedures in pl sql?
Does oracle use sql?
What is a common use of group by in sql?
What is sharding in sql?
What is data profiling in sql?
how do you control the max size of a heap table? : Sql dba
Can ddl statements be used in pl/sql?
What are stored procedures in mysql?
what is meant by nl2br()? : Sql dba
Why indexing is needed?
What is data control language (dcl)?
How do I quit sql?
What is the need of merge statement?
What is data modelling in sql?
Which sql statement is used to return only different values?