Main
GoodThought NGO has been a catalyst for positive change, focusing its efforts on education, healthcare, and sustainable development to make a significant difference in communities worldwide. With this mission, GoodThought has orchestrated an array of assignments aimed at uplifting underprivileged populations and fostering long-term growth.
This project offers a hands-on opportunity to explore how data-driven insights can direct and enhance these humanitarian efforts. In this project, you'll engage with the GoodThought PostgreSQL database, which encapsulates detailed records of assignments, funding, impacts, and donor activities from 2010 to 2023. This comprehensive dataset includes:
Assignments: Details about each project, including its name, duration (start and end dates), budget, geographical region, and the impact score.Donations: Records of financial contributions, linked to specific donors and assignments, highlighting how financial support is allocated and utilized.Donors: Information on individuals and organizations that fund GoodThought’s projects, including donor types.
Refer to the below ERD diagram for a visual representation of the relationships between these data tables:
You will execute SQL queries to answer two questions, as listed in the instructions. Good luck!
-- highest_donation_assignments
select asgn.assignment_name, asgn.region, round(sum(dnt.amount),2) as rounded_total_donation_amount, dn.donor_type
from assignments as asgn
inner join donations as dnt
on asgn.assignment_id = dnt.assignment_id
inner join donors as dn
on dnt.donor_id = dn.donor_id
group by dn.donor_type,asgn.assignment_name, asgn.region
order by rounded_total_donation_amount DESC
limit 5;
-- top_regional_impact_assignments
with asgn_rank_list as (
select asgn.assignment_id, asgn.assignment_name, asgn.region, asgn.impact_score, rank() over(partition by asgn.region order by asgn.impact_score desc) as asgn_rank
from assignments as asgn
)
select asgnl.assignment_name, asgnl.region, asgnl.impact_score, count(dnt.donation_id) as num_total_donations
from asgn_rank_list as asgnl
inner join donations as dnt
on asgnl.assignment_id = dnt.assignment_id
where asgnl.asgn_rank = 1
group by asgnl.assignment_name, asgnl.region, asgnl.impact_score
order by asgnl.region
limit 4;