Question: Write and run SQL statements to perform the following tasks by using the tables below: dd _ donor dd _ project dd _ status dd

Write and run SQL statements to perform the following tasks by using the tables below:
dd_donor
dd_project
dd_status
dd_pledge
dd_payment
a) List each donor who has made a pledge and paid in a single lump sum payment (i.e., where paymonths is equal to 0). Include the donors first name, last name, pledge date, and pledge amount.
SELECT
d.first_name,
d.last_name,
p.pledge_date,
p.pledge_amount
FROM
dd_donor d
JOIN
dd_pledge p ON d.donor_id = p.donor_id
JOIN
dd_payment pm ON p.pledge_id = pm.pledge_id
WHERE
pm.paymonths =0;
b) Display an unduplicated list of projects (ID and name) that have received pledges. Include only those projects with assigned pledges.
SELECT DISTINCT
p.project_id,
p.project_name
FROM
dd_project p
JOIN
dd_pledge pl ON p.project_id = pl.project_id;
c) Show the number of pledges made by each donor. Include the donor ID, first name, last name, and number of pledges.
SELECT
d.donor_id,
d.first_name,
d.last_name,
COUNT(p.pledge_id) AS number_of_pledges
FROM
dd_donor d
JOIN
dd_pledge p ON d.donor_id = p.donor_id
GROUP BY
d.donor_id,
d.first_name,
d.last_name;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!