I got to the correct answer according to the solution, but I think this is not correct. because I need “makes a recommendation for the three artists whose albums we should purchase for the store,”.
Anyone gets correct answer?
WITH qty_per_genre AS
SELECT il.quantity, g.name
FROM invoice i
INNER JOIN invoice_line il ON il.invoice_id=i.invoice_id
INNER JOIN track t ON t.track_id=il.track_id
INNER JOIN genre g ON g.genre_id=t.genre_id
SELECT name genre, SUM(quantity) as qty_sold,
CAST(SUM(quantity) AS FLOAT)/(SELECT COUNT(*) FROM qty_per_genre)
GROUP BY genre ORDER BY qty_sold DESC
Looks like you’ve done all the hard work and now it’s just a matter of using the results to drive your decision!
Based on your results, which artists, based on the genre of music they produce, should we should purchase for the store?
Last step would be to display a sorted table of top selling Rock artists and declare “selected because greater than 53% of the sales are rock” , and flat declare which are the top 3 selling performers.
The part that’s easy to gloss over for these projects is that “you are practicing for ‘how to explain these answers’ to people that may be half paying attention and half understand”.