Write a query that returns the Genres that I have purchased the most tracks of. I only care about genres that I've purchased at least 10 tracks of. Please ignore any tracks costing a dollar or more (they are primarily TV shows). Please output two columns, the name of the genre ("Genre_Name") and the number of tracks purchased ("Number_Purchased"). Order from most purchases to least.

Answer :

tariqasghar

Answer:

SQL Query

///////////////////////////////////////////////////////////////////////////////////////////////////

select Genre_Name, Number_Purchased from Genre

INNER JOIN Tracks on Genre.Genre_Name = Tracks.Genre_Name

WHERE Number_Purchased >= 10 AND Tracks.price >= 1

ORDER BY Number_Purchased ASC;

Explanation:

First off, I selected the required columns from Genre Table.

Then I inner joined Genre table with Tracks table, to get the price of tracks of the corresponding Genres.

Then the required Where conditions are written, which includes one from the Tracks table.

Finally, the Order by statement is written by Number_Purchased column in ascending (ASC) order.

Other Questions