BLACK FRIDAY EXTRA SAVINGS EVENT - EXTENDED
START FREE

Some help with the 'less common joins assesment needed

Hi!

I have some problems with one of the questions of the less common joins assesment.

Link to question 3:
https://app.dataquest.io/m/2000598/less-common-joins-assessment/3/question-3

My Code for question 3:

SELECT g.name AS genre, SUM(i.total) AS total_revenue
  FROM genre AS g
  LEFT JOIN track AS t
    ON g.genre_id = t.genre_id
  LEFT JOIN invoice_line AS il
    ON t.track_id = il.track_id
  LEFT JOIN invoice as i
    ON i.invoice_id = il.invoice_id
 GROUP BY g.name;

What actually happened:

Why do I get the feedback that I’m not joining the correct tables and do not use the correct join constraints?

Here’s a hint. The top three rows given by a correct answer are.

name total_purchased
Alternative 115.83
Alternative & Punk 487.08
Blues 122.76

Compare with your output. Realise it is incorrect and work towards figuring out that is the case.

A further hint:
Figure out how much money was made with the genre whose id 21 by looking only at invoice_line and track. Then see what your query does to this genre.

Hey Bruno,

I got the first three rows you produced, but still get the error ‘The query should calculate the amount sold for each genre’.

Please see this thread for more info.

Please ask your question in a separate post, unless your starting solution was the same as Leon’s.

Also, please include your code.