Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


select top 3 sal from each dept?

Answers were Sorted based on User's Feedback



select top 3 sal from each dept?..

Answer / avinesh gupta

select top 3 sal,depno from emp where deptno in
(
select deptno from emp group by deptno
)
order by sal desc

Is This Answer Correct ?    0 Yes 1 No

select top 3 sal from each dept?..

Answer / anil

select * from(select ename,deptno,sal from emp order by sal desc) where rownum<=3

Is This Answer Correct ?    0 Yes 1 No

select top 3 sal from each dept?..

Answer / sambu

select r.sal,r.rank,r.dept high from
(select deptno,sal,dense_rank() over (partition by deptno
order by sal desc) rank
from emp) r
where r.rank=3;


The above query gives the following result

DEPTNO SAL HIGHEST
------ ----- -------
10 1300 3
20 1100 3
30 1500 3

Is This Answer Correct ?    3 Yes 7 No

select top 3 sal from each dept?..

Answer / kishore

select * from (
select sal,rownum as num from (select sal from
emp order by sal desc))
where num <=3;

Is This Answer Correct ?    0 Yes 4 No

select top 3 sal from each dept?..

Answer / neetika vardhan

SELECT DEPT, MAX(SAL)
FROM EMP
WHERE SAL NOT IN (SELECT MAX(SAL) FROM EMP GROUP BY DEPT)
GROUP BY DEPT

UNION

SELECT DEPT, MAX(SAL)
FROM EMP
GROUP BY DEPT

UNION

SELECT DEPT, MAX(SAL)
FROM EMP
WHERE SAL NOT IN
(SELECT MAX(SAL)
FROM EMP
WHERE SAL NOT IN (SELECT MAX(SAL) FROM EMP GROUP
BY DEPT)
GROUP BY DEPT

UNION

SELECT MAX(SAL) FROM EMP GROUP BY DEPT)
GROUP BY DEPT

Is This Answer Correct ?    0 Yes 6 No

select top 3 sal from each dept?..

Answer / sen

select *
(select sal from emp
order by 1 desc)
where rownum < 4

Is This Answer Correct ?    1 Yes 13 No

select top 3 sal from each dept?..

Answer / asksam

Easy method to find top 3 sal -

Select distinct top 3 (sal) from emp order by sal desc

Is This Answer Correct ?    10 Yes 27 No

Post New Answer

More SQL PLSQL Interview Questions

How to know the last executed procedure?

0 Answers  


Explain aggregate functions are available there in sql?

0 Answers  


What is loop in pl sql?

0 Answers  


what is a control file ? : Sql dba

0 Answers  


Can we create index on primary key?

0 Answers  


Can you join views in sql?

0 Answers  


Explain the usage of WHERE CURRENT OF clause in cursors ?

3 Answers  


What is the use of sql trace?

0 Answers  


Can procedure in package be overloaded?

0 Answers   EXL,


How do you break a loop in pl sql?

0 Answers  


What are Lexical Parameters.How They are used in Reports 6i

2 Answers   eicc,


what are the forced views

6 Answers   Hexaware, TCS,


Categories