i need department wise top 2 employees salary.which logic
i will use

Answer Posted / kavitha

SELECT distinct a.department_id, a.salary
FROM (SELECT department_id, salary,
DENSE_RANK () OVER (PARTITION BY department_id ORDER BY salary DESC NULLS LAST) max_sal
FROM employees
WHERE department_id IS NOT NULL) a
WHERE max_sal <= 2

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it possible to remove child records without removing master table records...the two having pk,fk relationship?

804


What is full join?

525


What is nvl?

611


How can the performance of a trigger be improved?

588


Which join condition can be specified using on clause?

514






What are the benefits of pl sql?

524


Explain mutating table error.

645


Is sqlite good enough for production?

531


Why do we need sharding?

525


Explain raise_application_error.

641


What is error ora-12154: tns:could not resolve the connect identifier specified?

585


What is break?

616


What is a native sql query?

494


what is union? : Sql dba

580


What is trigger and how to use it in sql?

536