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

List the various privileges that a user can grant to another user?

585


Do stored procedures prevent sql injection?

552


Does asenumerable execute the query?

605


how are mysql timestamps seen to a user? : Sql dba

564


What is sqlcommand?

557






What types of commands can be executed in sql*plus?

554


what is bdb (berkeleydb)? : Sql dba

574


What is rename command in sql?

467


what is not null constraint? : Sql dba

552


Is sql pronounced sequel or sql?

742


What is the syntax to add a record to a table?

577


How do I save the results of sql query in a file?

535


how to include numeric values in sql statements? : Sql dba

563


Which command is used to delete a trigger?

777


Explain alias in sql?

584