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
What are the 3 types of behavioral triggers?
how many tables will create when we create table, what are they? : Sql dba
What is a pdo connection?
what is top in tsql? : Transact sql
What are the advantages of indexing?
How can I change database name in sql?
Explain what is a field in a database and record in a database?
What is the order of sql select?
what are the differences between binary and varbinary? : Sql dba
what is self join and what is the requirement of self join? : Sql dba
What is the current version of sql?
Explain how exception handling is done in advance pl/sql?
what does the t-sql command ident_current does? : Transact sql
How do you determine the current isolation level? : Transact sql
Why cannot I use bind variables in ddl/scl statements in dynamic sql?