471,073 Members | 1,299 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

MAX(SUM(SAL))not working

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
2 4224
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
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.

Similar topics

2 posts views Thread by Gary | last post: by
6 posts views Thread by Mullin Yu | last post: by
8 posts views Thread by Hardy Wang | last post: by
5 posts views Thread by Martin Heuckeroth | last post: by
5 posts views Thread by tshad | last post: by
8 posts views Thread by jojobar | last post: by
2 posts views Thread by Don | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.