-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d10c25b
commit 9fbacb7
Showing
5 changed files
with
36 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
WITH ARTIST_SPEND ( Id, Spend ) AS | ||
( | ||
SELECT al.ArtistId, SUM( al.Price ) | ||
FROM ALBUMS al | ||
GROUP BY al.ArtistId | ||
) | ||
SELECT a.Id, | ||
a.Name, | ||
COUNT( DISTINCT al.Id ) AS "Albums", | ||
COUNT( DISTINCT t.Id ) AS "Tracks", | ||
asp.Spend AS "Spend" | ||
FROM ARTIST_SPEND asp | ||
INNER JOIN ARTISTS a ON a.Id = asp.Id | ||
INNER JOIN ALBUMS al ON al.ArtistId = a.Id | ||
INNER JOIN TRACKS t ON t.AlbumId = al.Id | ||
WHERE IFNULL( al.IsWishListItem, 0 ) = $wishlist | ||
GROUP BY a.Id, a.Name | ||
ORDER BY a.Name ASC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
WITH ALBUM_SUMMARY ( Id, ArtistId, Genre, Tracks, Price, IsWishListItem ) AS | ||
( | ||
SELECT a.Id, a.ArtistId, a.Genre, COUNT( t.Id ), IFNULL( a.Price, 0 ), IFNULL( a.IsWishListItem, 0) | ||
FROM ALBUMS a | ||
INNER JOIN TRACKS t ON t.AlbumId = a.Id | ||
GROUP BY a.Id, a.ArtistId, a.Genre, a.Price | ||
SELECT a.Id, | ||
a.ArtistId, | ||
a.Genre, | ||
COUNT( t.Id ), | ||
IFNULL( a.Price, 0 ), | ||
IFNULL( a.IsWishListItem, 0) | ||
FROM ALBUMS a | ||
INNER JOIN TRACKS t ON t.AlbumId = a.Id | ||
GROUP BY a.Id, a.ArtistId, a.Genre, a.Price | ||
) | ||
SELECT Genre, COUNT( DISTINCT ArtistId) AS "Artists", COUNT( DISTINCT Id ) AS "Albums", SUM( Tracks ) AS "Tracks", SUM( Price ) AS "Spend" | ||
FROM ALBUM_SUMMARY | ||
WHERE IsWishListItem = $wishlist | ||
GROUP BY Genre | ||
ORDER BY Genre ASC; | ||
SELECT Genre, | ||
COUNT( DISTINCT ArtistId) AS "Artists", | ||
COUNT( DISTINCT Id ) AS "Albums", | ||
SUM( Tracks ) AS "Tracks", | ||
SUM( Price ) AS "Spend" | ||
FROM ALBUM_SUMMARY | ||
WHERE IsWishListItem = $wishlist | ||
GROUP BY Genre | ||
ORDER BY Genre ASC; |
File renamed without changes.
File renamed without changes.
File renamed without changes.