开发者

PHP: Sum list of values

开发者 https://www.devze.com 2023-01-07 12:04 出处:网络
I have a list of information like this... No. Customer Bank_Name Amount ----------------------------- 1.AAABank A100

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
0

精彩评论

暂无评论...
验证码 换一张
取 消