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


Please Help Members By Posting Answers For Below Questions

What is the difference between stored procedure and view?

535


What is the difference between delete and truncate commands?

517


Can we rollback after truncate?

570


What are the benefits of triggers?

606


How much does a sql dba make? : SQL DBA

512






Explain the methods used to protect source code of pl/sql.

548


What is the difference between a primary key and a unique key?

563


When sql appeared?

625


What are stuff and replace function?

578


What is the difference between alter trigger and drop trigger statements?

605


Explian rowid, rownum? What are the psoducolumns we have?

576


How many triggers can be applied on a table?

515


What is a sql profiler?

592


how can we optimize or increase the speed of a mysql select query? : Sql dba

515


What do you mean by field in sql?

538