SUM and GROUP

Hi


Whats wrong with this statment?

SELECT
FROM `orders` SUM(del) AS TotalPicked
WHERE datepackedtimestamp = '1196640000'
GROUP BY packedby
ORDER BY packedby

I'm trying to end up with a list of a summed up del from each packed by

EG
John 46
Fred 189
Harry 24

Thanks

Brian







------------------------------------------------------------ --------------------
I am using the free version of SPAMfighter for private users.
It has removed 564 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!
Brian [ Mo, 03 Dezember 2007 19:44 ] [ ID #1884676 ]

Re: SUM and GROUP

Post removed (X-No-Archive: yes)
Notifier Deamon [ Mo, 03 Dezember 2007 20:00 ] [ ID #1884677 ]

Re: SUM and GROUP

"Tom" <tom [at] to.com> wrote in message news:fj1joo021is [at] drn.newsguy.com...
> On Mon, 03 Dec 2007 18:44:46 GMT, Brian wrote...
>>
>>Hi
>>
>>
>>Whats wrong with this statment?
>>
>>SELECT
>>FROM `orders` SUM(del) AS TotalPicked
>>WHERE datepackedtimestamp = '1196640000'
>>GROUP BY packedby
>>ORDER BY packedby
>>
>>I'm trying to end up with a list of a summed up del from each packed by
>>
>>EG
>>John 46
>>Fred 189
>>Harry 24
>>
>>Thanks
>>
>>Brian
>>
>
> Hi Brian,
>
> I think you need to put the column names and functions in the SELECT part
> of
> your query and the table name(s) in the FROM part. If you are using the
> SUM
> function with the GROUP BY, that should get you the totals for 'del'.
>
> Tom


Not sure what i was thinking the SUM(del) AS TotalPicked should have been
before
the FROM, DOH !!!

Brian



------------------------------------------------------------ --------------------
I am using the free version of SPAMfighter for private users.
It has removed 637 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!
Brian [ Mi, 05 Dezember 2007 02:06 ] [ ID #1886422 ]
PHP » alt.php.sql » SUM and GROUP

Vorheriges Thema: Re: Using PHP to Database Tables via Email
Nächstes Thema: How do I copy a table for backup and restore purposes