By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,237 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,237 IT Pros & Developers. It's quick & easy.

MAX(SUM(SAL))not working

P: n/a
mk
Hi all,

I have a dept table with following structure like

Column
-------------
DEPTNO
SAL

I want to get to maximum renumeration paid to each department......

max(sum(sal)) is not working....

Any ideas regading....

Adv thanks Reg

Sep 6 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
mk wrote:
Hi all,

I have a dept table with following structure like

Column
-------------
DEPTNO
SAL

I want to get to maximum renumeration paid to each department......

max(sum(sal)) is not working....

Any ideas regading....

Adv thanks Reg
You want the department with the biggest salary expense?

The easiest I can think of is:
SELECT dept, SUM(salary) FROM emp
GROUP BY dept
ORDER BY 2 DESC FETCH FIRST ROW ONLY

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Sep 6 '06 #2

P: n/a
mk

Serge Rielau wrote:
mk wrote:
Hi all,

I have a dept table with following structure like

Column
-------------
DEPTNO
SAL

I want to get to maximum renumeration paid to each department......

max(sum(sal)) is not working....

Any ideas regading....

Adv thanks Reg
You want the department with the biggest salary expense?

The easiest I can think of is:
SELECT dept, SUM(salary) FROM emp
GROUP BY dept
ORDER BY 2 DESC FETCH FIRST ROW ONLY

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/

Thanks for helping me out.....

Sep 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.