Answered step by step
Verified Expert Solution
Link Copied!
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(50) NOT NULL
TABLE donations
id INTEGER PRIMARY KEY
amount INTEGER NOT NULL
year INTEGER NOT NULL
benefactorId INTEGER
FOREIGN KEY (benefactorId) REFERENCES
benefactors(id)
Some donations are received from anonymous sources (benefactorld is null).
Write a query that returns:
Benefactor names.
Sum of their contributions for the year 2015.
Benefactors who haven't been able to contribute in the year 2015, should also be returned with their contribution as 0. All anonymous contributions should be summed under the name 'Anonymous'. If there are no anonymous contributions for the year 2015, no rows with the name 'Anonymous' should be returned.
See the example case for more details.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students explore these related Databases questions