Queries 3
- Due Mar 9, 2015 by 11:59pm
- Points 7
- Submitting a file upload
- Available after Mar 6, 2015 at 11:30am
Using the class_music_festival, answer these 7 questions. For each query, show the intermediate queries, the final query and the result that you get. If you are having trouble getting the syntax exactly, just write out what you think the recipe for getting to the answer is, that's really at least half the battle. Remember to do all your joins before ORDER BY and GROUP BY. If you see a "disconnected from server" in phpmyadmin that means you missed a join condition (e.g. SELECT * FROM tickets, purchases, without the needed WHERE clause).
**You can find the basic result solutions to questions 1-4 in this document. Please note that you will still need to step through the queries and show all of your work.
- What is the name of the person who spent the most (and how much did they spend)?
- Which performance had the highest revenue? (ticket prices are incoming income, thus revenue)
- Which performance was the most profitable? (profit is revenue - costs. bands.fee is the cost)
- Which band was the least profitable for the festival? (note: bands are paid their fee for each performance, hint: dealing with that requires a COUNT(DISTINCT ...) within a group) (If you have trouble with this one, just do as though they are only paid the fee once).
- Which venues were oversold (and what were their capacities)? (hint: this should use a HAVING clause) (oversold requires math around capacity)
- What was the total revenue from ticket sales each month? (hint: needs MONTH(date) in the SELECT clause)
- What was the average purchase total each month? (note: purchase total is the sum of the price of tickets bought together in the same purchase, Q1 in in-class exercises.) (two ways to get this done, one that uses AVG and that uses /).