Database SQL: You can download the table from this link: https://drive.google.co
ID: 3589332 • Letter: D
Question
Database SQL:
You can download the table from this link:
https://drive.google.com/file/d/0B0kVn308bqFuZkFULTBSU1lzdEk/view?usp=sharing
1. For each of the local zip codes, and each of the candidates, show the number of contributions (if at least one contribution was made). Order by zip code and then number of contributions.
........................................
2. Who are the top 10 local contributors in terms of total amount contributed? Show the contributor names and the amount they spent.
........................................
3. Show date and amount for all contributions from 'BATTS, ERIC'. Order by amount, decreasing.
........................................
4. On average, how many contributions did each contributor make? Give a single number, rounded to one digit to the right of the decimal point.
........................................
Explanation / Answer
1. select c.name, count(cn.contb_id) contributorno from candidate c,contribution cn,contributor cb where cb.contbr_id=cn.contb.id and cb.zip like '926%' order by cb.zip,contributorno;
2. select contb_id,amount from contribution where rownum<=10;
3. select cn.date,cn.amount from contribution cn,contributor cb where cn.contb_id=cb.contbr_id and cb.name='BATTS, ERIC' order by cn.amount desc;
4. select cb.contb_id, round(avg(count(cn.amount,1))) from contribution cn,contributor cb where cn.contb_id=cb.contbr_id group by cb.contb_id;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.