开发者

help with SQL queries

Given the following diagram:

help with SQL queries

Right now I have queries to find out how much each member has donated and also listing those donations in a list for each member. Now I want to query the donations table to get the results divided up by each organization.

Something like:

help with SQL queries

Can someone pl开发者_开发问答ease help me with this SQL?


Assuming that you're using MySQL:

SELECT
    MemberId,
    OrganizationId,
    SUM(Amount) AS `Amount Donated to Organization`,
    COUNT(Amount) AS `Number of Donations`
FROM
    Donations
GROUP BY
    MemberId,
    OrganizationId
;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜