i need department wise top 2 employees salary.which logic
i will use
Answer Posted / ashok kumar y
SELECT a.deptno, a.sal
FROM (SELECT deptno, sal,
DENSE_RANK () OVER (PARTITION BY deptno ORDER BY sal DESC NULLS LAST) max_sal
FROM emp
WHERE deptno IS NOT NULL) a
WHERE max_sal <= 2 group by deptno,sal ;
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Which is faster subquery or join?
how to shutdown mysql server? : Sql dba
Is sql considered coding?
What is schema in sql?
When is the update_statistics command used?
How do you select unique values in sql?
Can we have two clustered index on a table?
What is the difference between join and natural join?
what is subquery? : Sql dba
Is id a reserved word in sql?
Can primary key be changed?
Is foreign key mandatory?
What is trigger in sql?
how to create a test table in your mysql server? : Sql dba
What is the difference between left outer join and left join?