select top 3 sal from each dept?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Answer / sen
select *
(select sal from emp
order by 1 desc)
where rownum < 4
Is This Answer Correct ? | 1 Yes | 13 No |
wtite down triggr not any entry on Sunday
What are the parts of a basic sql query?
how to delete duplicate rows from a join tables(I have three tables on that join) how do you know which join is need to be used? The select statement I have is: SELECT gc_skill_type.skill_type, gc_area_tec.area, gc_technology.technology, gc_technology.id_technology, gc_area_tec.id_area_tec FROM gc_skill_type, gc_area_tec, gc_technology WHERE gc_area_tec.id_skill_type (+) = gc_skill_type.id_skill_type AND gc_technology.id_area_tec (+) = gc_area_tec.id_area_tec order by gc_skill_type.skill_type asc, gc_area_tec.area asc, gc_technology.technology asc
Why do we use joins?
What is a join?Explain the different types of joins?
6 Answers Bank Of India, CitiGroup, Google, ICICI, Saama Tech, SkyTech, TCS,
Explain the difference between sql and mysql.
What is procedure and function?
how to find the First and Last Observation from the table: Ex: OBS Name Sal Ans like: OBS Name Sal 105 E 5000--> 105 E 5000 102 B 2000 104 D 4000 103 C 3000 101 A 1000--> 104 D 4000
How pl/sql source code can be protected?
What is the Subquery?
Is oracle and sql same?
Is left join faster than join?