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!

Spinner
DataFrameas
highest_donation_assignments
variable
-- highest_donation_assignments
SELECT a.assignment_name,
a.region,
ROUND(SUM(donations.amount),2) AS rounded_total_donation_amount,
donors.donor_type
FROM assignments AS a
RIGHT JOIN donations ON donations.assignment_id = a.assignment_id
JOIN donors ON donors.donor_id = donations.donor_id
GROUP BY donors.donor_type, a.assignment_name, a.region
ORDER BY rounded_total_donation_amount DESC
LIMIT 5;
Spinner
DataFrameas
top_regional_impact_assignments
variable
-- top_regional_impact_assignments
WITH total_donations AS (SELECT a.assignment_id,
	COUNT(donor_id) AS num_total_donations
	FROM assignments AS a
	RIGHT JOIN donations ON donations.assignment_id = a.assignment_id
	GROUP BY a.assignment_id),
 assignment_ranks AS (SELECT a.assignment_id,
	ROW_NUMBER() OVER(PARTITION BY a.region ORDER BY a.impact_score DESC) AS assignment_rank
	FROM assignments AS a
	JOIN total_donations ON total_donations.assignment_id = a.assignment_id
	WHERE num_total_donations > 0
	GROUP BY a.assignment_id, a.region, a.impact_score)

SELECT a.assignment_name,
a.region,
a.impact_score,
num_total_donations
FROM assignments AS a
JOIN total_donations ON total_donations.assignment_id = a.assignment_id
	JOIN assignment_ranks ON assignment_ranks.assignment_id = a.assignment_id
	WHERE assignment_rank = 1
GROUP BY a.assignment_name, a.region, a.impact_score, num_total_donations
ORDER BY a.region ASC;