i need department wise top 2 employees salary.which logic
i will use
Answer Posted / nag
select distinct(sal), deptno from
(select * from emp a where 1 = (select count(distinct sal)+1
from emp b where b.sal > a.sal and b.deptno = a.deptno) and
deptno is not null
union
select * from emp a where 2 = (select count(distinct sal)+1
from emp b where b.sal > a.sal and b.deptno = a.deptno)and
deptno is not null)
order by deptno,sal
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Can we use ddl commands in pl sql?
What is embedded sql with example?
What is the purpose of primary key?
Can we use ddl statements in stored procedure sql server?
How to rename a column in the output of sql query?
what are the t string functions available in tsql? : Transact sql
What types of commands can be executed in sql*plus?
Explain what is a subquery ?
Can you selectively load only those records that you need? : aql loader
How many types of functions are there in sql?
Which join is like an inner join?
Is it possible for a table to have more than one foreign key?
Lookups are a key component in sql server integration services (ssis). Explain its purpose?
Can I join the same table twice?
differentiate between float and double. : Sql dba