如何在捐赠者表mysql中获得捐赠者的总数 [英] how to get the total amount of donors in a donor table mysql

查看:71
本文介绍了如何在捐赠者表mysql中获得捐赠者的总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,





在我的应用程序中我想存储捐赠者的详细信息,所以我创建了一个捐赠者表,其中包含一些字段捐赠者姓名,金额等。同一捐赠者可以随时捐款。所以我想得到每个捐赠者捐赠的总金额有什么办法吗?



谢谢

Ginnas

hello,


in my application i wanted to store donor details ,so i have created a donor table with some field like donor name, amount etc.. same donor can donate amounts any time. so i wanted to get the total amounts donated by each donors is there any way?

Thanks
Ginnas

推荐答案

您需要 SUM 函数和 GROUP BY 子句。

You need the SUM function and a GROUP BY clause.
Something like
SELECT donor, SUM(donation) as TotalAmount
From MyTable
Group By donor


嗯,你需要使用聚合函数来获得总金额。

您需要使用Group by子句对每个捐赠者的总金额进行分组。



Well, you need to use the aggregate function to get the total amount.
And you need to use the Group by clause to group the total amount from each donor.

select donor, sum(amount) from tbl_x group by donor





这就是全部。

我希望这会对你有帮助。



that''s all.
I hope this helps you.


这篇关于如何在捐赠者表mysql中获得捐赠者的总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆