GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 105 of 171    Print  
How do i get Greatest salaray of dept group from emp and dept?
we have to tables EMP and DEPT. for exp: dept 10 have 10000,dept 20 have 5000 and dept 30 have 15000 salaries, i need dept 30 group salary(means sum of that group is 15000).

  
Total Answers and Comments: 14 Last Update: February 08, 2008     Asked by: SRINIVAS 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
October 23, 2006 10:14:48   #1  
nagaraju_thumati        

RE: How do i get Greatest salaray of dept group from e...
ya u can use this quiery i think no need to use dept table bcz already emp has that attribute select max(sal) from empwhere sal any ( select max(sal) from emp group by deptno);
 
Is this answer useful? Yes | No
October 25, 2006 06:09:50   #2  
sarfaraz ahmad        

RE: How do i get Greatest salaray of dept group from e...
select max(a.sal) b.deptname from emp a dept b where a.deptno b.deptno group by b.deptname
 
Is this answer useful? Yes | No
October 26, 2006 16:39:58   #3  
Srinivas        

RE: How do i get Greatest salaray of dept group from e...

both answers r wrong i want the greatest salaries group of sum(sal).

means if deptno 10 have sum(sal) 10000

20 have sum(sal) 15000

30 have sum(sal) 12000

i need answer is : 20 15000

beacause dept 20 have greatest sum.

Srinivas


 
Is this answer useful? Yes | No
October 30, 2006 01:02:27   #4  
Padmanabham        

RE: How do i get Greatest salaray of dept group from e...

select deptno max(sum(salary))

from EMP group by deptno;


 
Is this answer useful? Yes | No
November 02, 2006 02:00:59   #5  
BRAJESH KUMAR        

right answer is as : How do i get Greatest salaray of dept group from e...

I TAKE THE EMP AND DEPT TABLE FROM SCOTT AND TIGER.

SELECT * FROM (SELECT SUM(SAL)MAXSAL DEPT.DNAME FROM EMP DEPT WHERE EMP.DEPTNO DEPT.DEPTNO GROUP BY DNAME ORDER BY SUM(SAL)DESC )WHERE ROWNUM 1


 
Is this answer useful? Yes | No
November 02, 2006 22:50:55   #6  
tanveer        

RE: How do i get Greatest salaray of dept group from e...
select deptno sum(sal)
from emp
group by deptno
having (deptno sum(sal)
select deptno
from emp
group by deptno
having max(sum(sal))

 
Is this answer useful? Yes | No
November 22, 2006 00:46:56   #7  
Swathi        

RE: How do i get Greatest salaray of dept group from e...

To Get the Max sal of each department

select max(sal) deptno from emp where sal in(select max(sal) from emp group by deptno) group by deptno;


 
Is this answer useful? Yes | No
December 18, 2006 00:03:37   #8  
Abhijit AUddy        

RE: How do i get Greatest salaray of dept group from e...
select * from (select max(sal) deptno from emp group by deptno) where rownum < 1;
 
Is this answer useful? Yes | No
December 18, 2006 15:49:10   #9  
Manish Agarwal        

RE: How do i get Greatest salaray of dept group from e...

Executed and tested in Oracle 8i :-

select * from (
select e.dept sum(e.sal) esal
from emp e dept d
where e.deptid d.deptid
group by e.deptid
order by sum(e.sal) desc
) where rownum 1;


 
Is this answer useful? Yes | No
December 20, 2006 06:38:01   #10  
Sai Srinivas Vartha        

RE: How do i get Greatest salaray of dept group from e...

select deptno sal1 from (select sum(sal) sal1 deptno from scott.emp group by deptno order by sal1 desc) where rownum < 1


 
Is this answer useful? Yes | No
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape