Re: summing data within a table
| From: | php3 at developersdesk dot com | Date: | Tue, 03 Oct 2000 01:34:35 +0000 |
| Subject: | Re: summing data within a table | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-3239@lists.php.net to get a copy of this message | ||
Addressed to: "Mark McCray" <mm@tbwachiat.com>
php-db@lists.php.net
** Reply to note from "Mark McCray" <mm@tbwachiat.com> Mon, 02 Oct 2000 20:10:29
-0400
>
> Hey all, I'm not sure how to go about this, but here goes:
>
> I have one table, it's sort of like an invoice items table.
>
> It's made up of employees, dates, and amounts.
>
> How do I summarize all the different items belonging to each employee and
> sum their amounts.
>
> so if I have:
>
> 1-1-2000 Mark 2000.00
> 1-1-2000 Debbie 3000.00
> 1-4-2000 Lenny 3050.89
> 2-8-2000 Mark 1500.00
> 2-24-2000 debbie 2000.00
> 3-3-2000 Lenny 8000.00
>
> How do I make a summary where it shows:
>
> Mark totals 4500.00
> Debbie totals 5000.00
> and
> Lenny totals 11050.89
>
> I think this might be db 101, but I'm a little fuzzy on it. Marky
SELECT Name, SUM( Amount ) AS Sum FROM Table ORDER BY Name GROUP BY Name;
Rick Widmer
Internet Marketing Specialists
www.developersdesk.com