Hi Fred, group,

I wrote--
>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?
> 

you wrote--
I guess you want to use a GROUP BY because the SUM makes no 
sense without it. You seem to want results for unique 
combinations of Job, Sub and Task. This means:

GROUP BY Jobs.Job, Jobs.Sub, Jobs.Task;
--end


You're right.  I want the output to be

Jobs.ID   Jobs.Job  Jobs.Sub  Jobs.Task  Amount
87        A01       A         19         10,127.98
929       B53       A         201        79.47
998       X99       L         88         38,289.02

I should have mentioned that I'd already tried GROUP BY as you suggest, but the error 
message I receive is that ID was not included as part of the aggregate function.  I'm 
not sure whether this means the ID field in the Jobs table or the one in the 
Funds_Recd table.  Is there another way of accomplishing this?  Subselect maybe or a 
temp table derived from Funds_Recd?

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