开发者

help with SQL queries

开发者 https://www.devze.com 2023-03-28 02:39 出处:网络
Given the following diagram: 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

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

精彩评论

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