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:
dddonor
ddproject
ddstatus
ddpledge
ddpayment
a List each donor who has made a pledge and paid in a single lump sum payment ie where paymonths is equal to Include the donors first name, last name, pledge date, and pledge amount.
SELECT
dfirstname,
dlastname,
ppledgedate,
ppledgeamount
FROM
dddonor d
JOIN
ddpledge p ON ddonorid pdonorid
JOIN
ddpayment pm ON ppledgeid pmpledgeid
WHERE
pmpaymonths ;
b Display an unduplicated list of projects ID and name that have received pledges. Include only those projects with assigned pledges.
SELECT DISTINCT
pprojectid
pprojectname
FROM
ddproject p
JOIN
ddpledge pl ON pprojectid plprojectid;
c Show the number of pledges made by each donor. Include the donor ID first name, last name, and number of pledges.
SELECT
ddonorid
dfirstname,
dlastname,
COUNTppledgeid AS numberofpledges
FROM
dddonor d
JOIN
ddpledge p ON ddonorid pdonorid
GROUP BY
ddonorid
dfirstname,
dlastname;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
