G'day all,

Having trouble with SUM, could use a hand.  I inherited a table, Funds_Recd that looks 
like this:

ID   Job  Sub  Task  Amt
1    A01  A    19    10,001.00
102  B53  A    201   79.47
213  X99  L    88    38,289.02
284  A01  A    19    126.98

I do not have ownership and *MAY NOT* change the structure.

I've another table, Jobs, to which the Funds_Recd recs must be related:

ID   Job  Sub  Task
87   A01  A    19
929  B53  A    201
998  X99  L    88

This query works --

SELECT Jobs.Job, Jobs.Sub, Jobs.Task, Funds_Recd.Amt
FROM Jobs, Funds_Recd
WHERE Jobs.Job=Funds_Recd.Job and Jobs.Sub=Funds_Recd.Sub and Jobs.Task=Funds_Recd.Task
ORDER BY Jobs.Job;

but produces a list of jobs with individual rows for the various funds amounts.  I'm 
trying to get just a total of the funds amount for a Job, Sub and Task like this --

SELECT Jobs.Job, Jobs.Sub, Jobs.Task, sum(Funds_Recd.Amt) AS Amount
FROM Jobs, Funds_Recd
WHERE Jobs.Job=Funds_Recd.Job and Jobs.Sub=Funds_Recd.Sub and Jobs.Task=Funds_Recd.Task
ORDER BY Jobs.Job;

but this produces an error telling me I'm not using Jobs.ID in the aggregate function.

Is there a way to generate this query without adding the Jobs.ID column to the 
Funds_Recd table?

TIA, Glen



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to