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 sql used for?

642


Why should I use postgresql?

561


How can we find duplicate records in a table?

512


How do you modify a column in sql?

531


What is consistency?

708






Why do we use procedures?

512


Does postgresql run on the cloud?

586


What is output spooling in sql*plus?

549


What are different clauses used in sql?

583


What are the usages of sql?

562


What sql database should I use?

547


What is query syntax?

519


Is left join faster than join?

538


What is the difference between union and union all command?

544


What are character functions in sql?

494