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
Is join an inner join?
What is foreign key in sql with example?
Is sql scripting language?
How do I view a view in sql?
How does join work in sql?
Can we perform dml in function?
What is the difference between having clause and where clause?
Which one is better subquery or joins?
Is sqlite thread safe?
what are the differences between require and include, include_once and require_once? : Sql dba
How many types of primary keys are there?
what is 'mysqldump'? : Sql dba
What is rename command in sql?
How to connect a sql*plus session to an oracle server?
What is parameter substitution in sql?