Home /
Expert Answers /
Other /
using-sql-database-is-chinook-can-use-cte-ranking-over-aggregates-partition-chinook-entity-relations
(Answered): Using SQL, Database is Chinook. Can use CTE, Ranking, Over,Aggregates, Partition. Chinook Entity ...
Using SQL, Database is Chinook. Can use CTE, Ranking, Over,Aggregates, Partition.
Chinook Entity Relationship Diagram Artist Artistid Name 00- Album Albumid Title Artistid MediaType MediaTypeid Name Track - Trackid Name Albumid MediaTypeid Genreid Composer Milliseconds Bytes UnitPrice Genre -3-00 Playlist Playlistid Name Playlist Track Playlistid Tracked Genreld Name InvoiceLine InvoiceLineld Invoiceld Trackid UnitPrice Quantity 00 Employee Employeeld LastName FirstName Title Reports To BirthDate HireDate Address City State Country PostalCode Phone Fax Email Customer Customerid FirstName LastName Company Address City State Country PostalCode Phone Fax Email SupportRepid 3-00 Invoice 7 Invoiceld Customerid InvoiceDate BilingAddress Billing City BilingState Billing Country BilingPostal Code Total Window Functions and Randomization 4. Find top all time sales in the database by Album, and rank them. (24 Rows) The result sel will contain 6 columns. ArlislName, Album Tille, TotalSales, Media, Rariking, and DenseRanking. Media will either be Audio or video. Use the MediaType table to determine the media. Ranking will use the RANK function and DenseRanking will use the DENSE_RANK function. Order the rankings by TotalSales and Partition the rankings by Audio and Video Media types. Only return albums whose TotalSales are greater than 15. 8 15 16 17 18 19 20 Artist Name Album Title U2 Rattle And Hum U2 Instant Kama: The Amnesty International Campai Chico Science & Nação Zumbi Mrocberdelia Battlestar Galactica (Classic) Battlestar Galactica (Classic), Season 1 The Office The Office, Season 3 Heroes Heroes. Season 1 TotalSales Media Ranking Dense Ranking 16.83 Audio 12 15 84 Audi 16 9 15.84 Audio 16 9 35.82 Video 3184 Video 2 2 25.87 Vdeo 3 3 1 1