Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A welfare organization has been receiving donations from benefactors over the years. The data is stored in the following tables: TABLE benefactors id INTEGER PRIMARY
A welfare organization has been receiving donations from benefactors over the years. The data is stored in the following tables:
TABLE benefactors
id INTEGER PRIMARY KEY
name VARCHAR NOT NULL
TABLE donations
id INTEGER PRIMARY KEY
amount INTEGER NOT NULL
year INTEGER NOT NULL
benefactorId INTEGER
FOREIGN KEY benefactorId REFERENCES
benefactorsid
Some donations are received from anonymous sources benefactorld is null
Write a query that returns:
Benefactor names.
Sum of their contributions for the year
Benefactors who haven't been able to contribute in the year should also be returned with their contribution as All anonymous contributions should be summed under the name 'Anonymous'. If there are no anonymous contributions for the year no rows with the name 'Anonymous' should be returned.
See the example case for more details.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started