📄
EBIS3003-2021
  • Introduction to the Course
  • Preliminaries
    • donorschoose.org
    • Installing Software
    • Sequel Pro Local Access
    • Import donorschoose.org Data to MySQL Server
    • MySQL Setting for Client Software
  • SQL
    • Class Activity 2 - Creating New Tables (Week 2)
    • Inserting Table
    • Select / Functions
    • Grouping
  • PYTHON
    • Installing Anaconda
    • Running Jupyter Notebook
    • Connecting MySQL via Python
  • Assignments
    • In-class Activity - ER (Week 5)
    • Homework Assignment 1
      • Solutions
    • Homework Assignment 2
    • In-Class Activity - Python (Week 11-12)
    • In-Class Activity - Normalization (Week 14)
Powered by GitBook
On this page
  • 1. Donations
  • 2. Donors

Was this helpful?

  1. Assignments
  2. Homework Assignment 1

Solutions

1. Donations

  • What is the average total amount (in $) of donations made to each project? If two donations that amount to $10 and $20 respectively were made to project A, the total donation to project A is $30.

SELECT AVG(sums)
FROM (SELECT SUM(total_amount) as sums
	FROM donations
    GROUP BY project_id) x ;
  • How many did unique projects receive a donation at least once according to donations table?

SELECT COUNT(DISTINCT project_id)
FROM donations;
  • Some donations 'complete' projects, meaning that those last donations made to projects enabled the projects to achieve the monetary goal they set up front. Whether a donation completes a project is recorded in the column completion. Are donations that complete projects substantially larger/smaller than other donations?

SELECT AVG(total_amount)
FROM donations
WHERE completion = 1;
SELECT AVG(total_amount)
FROM donations
WHERE completion = 0
AND funded = 1;

2. Donors

  • Count the numbers of donors from each state.

SELECT state, COUNT(1) as num
FROM donors
GROUP BY state;
  • Does average amount of donation (avg_total) differ between one-time donor (num_projeccts=1) v. more-than-once donor (num_projects>1)?

SELECT avg(avg_total)
FROM donors
WHERE num_projects = 1;
SELECT avg(avg_total)
FROM donors
WHERE num_projects > 1;

PreviousHomework Assignment 1NextHomework Assignment 2

Last updated 4 years ago

Was this helpful?