Summarising tables contents?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hebbs
Forum Commoner
Posts: 43
Joined: Mon Apr 22, 2002 9:34 pm
Location: Perth, Western Australia

Summarising tables contents?

Post by Hebbs »

I have a table that contains customer information as in Name, payment method (cash/cheque/c/card etc), date of transaction and amount paid.

I can extract and display all of these entries individually OK, but how can I extract a summary of sales that only shows the total of all types

e.g.

In this example EG SMITH may have made ten cheque purchases totalling $200 and three cash totalling $100. Each purchase is listed in the table but I want to display a summary result like this result something like this

EG SMITH Cheque $200.00
Cash $100.00
Total $300.00


AB BROWN Cash $400.00
Total $400.00

P WHITE CCard $300.00
Cash $250.00
Cheque $125.00
Total $675.00

etc etc

Hebbs
User avatar
haagen
Forum Commoner
Posts: 79
Joined: Thu Jul 11, 2002 3:57 pm
Location: Sweden, Lund

Post by haagen »

What type of table do you have? Is it a database table? How does it look like?
Hebbs
Forum Commoner
Posts: 43
Joined: Mon Apr 22, 2002 9:34 pm
Location: Perth, Western Australia

Post by Hebbs »

Got it,

Used GROUP BY in the SQL statement.

SHould have gone to MYSql first!

Thanks

Hebbs
Post Reply