Skip to content

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!

Top five assignments based on total value of donations, categorized by donor type:

Spinner
DataFrameas
highest_donation_assignments
variable
-- highest_donation_assignments
with total_donation as (
	select d1.assignment_id, d2.donor_type, sum(d1.amount) as aggregate_amount
	from donations as d1
	inner join donors as d2
	using (donor_id)
	group by d1.assignment_id, d2.donor_type)
select a.assignment_name,a.region,t.donor_type, round(aggregate_amount,2) as rounded_total_donation_amount
from assignments as a
inner join total_donation as t
using(assignment_id)
order by rounded_total_donation_amount desc
limit 5

Here I am Identifing the assignment with the highest impact score in each region, ensuring that each listed assignment has received at least one donation:

Spinner
DataFrameas
top_regional_impact_assignments
variable
-- top_regional_impact_assignments
with cte as 
	(select s.assignment_name,s.region,s.impact_score,row_number() over(partition by 	s.region order by s.impact_score desc) as rank,count(d1.donation_id) as 		 	num_total_donations
	from assignments as s
	inner join donations as d1
	on s.assignment_id = d1.assignment_id
	inner join donors as d2
	on d1.donor_id = d2.donor_id
	group by  s.assignment_name, s.region,s.impact_score
	order by  impact_score desc)
select assignment_name,region,impact_score,num_total_donations
from cte
where rank = 1
order by region asc