我有一个像这样的信息列表......
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
如何使用PHP为每个银行汇总此信息,因此结果如下所示......
No. Bank_Name Total
-------------------
1. Bank A 600
2. Bank B 200
3. Bank C 150
-------------------
答案 0 :(得分:3)
如果它在数据库中......类似于:
SELECT bank, SUM(amount) as `sum`
FROM customers
GROUP BY bank
ORDER BY bank