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
with donation as (select
r.donor_type,
a.assignment_name,
a.region,
round(sum(d.amount),2) as rounded_total_donation_amount
from public.donations d
join assignments a
using(assignment_id)
join donors r
on d.donor_id = r.donor_id
group by r.donor_type, a.assignment_name, a.region),
top as (select
donor_type,
assignment_name,
region,
rounded_total_donation_amount,
rank() over(order by rounded_total_donation_amount desc)
from donation)
select
donor_type,
assignment_name,
region,
rounded_total_donation_amount
from top
where rank <=5-- top_regional_impact_assignments
with high as (select
distinct a.assignment_name ,
region,
impact_score,
donation_id,
count(donation_id) over(partition by a.assignment_name) as num_total_donations,
dense_rank() over(partition by region order by impact_score desc) as rank
from assignments a
full join donations d
on a.assignment_id = d.assignment_id
where donation_id is not null)
select
distinct region,
assignment_name,
impact_score,
num_total_donations
from high
where rank = 1
limit 4