PHP: Sum list of values
I have a list of information like this...
No. Customer Bank_Name Amount
-----------------------------
1. AAA Bank A 100
2. BBB Bank B 200开发者_运维知识库
3. CCC Bank A 500
4. DDD Bank C 150
-----------------------------
Total 950
How can I sum this information for each bank, using PHP, so the result looks like this...
No. Bank_Name Total
-------------------
1. Bank A 600
2. Bank B 200
3. Bank C 150
-------------------
If it's in a database... something like:
SELECT bank, SUM(amount) as `sum`
FROM customers
GROUP BY bank
ORDER BY bank
精彩评论