-
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
9fbacb7
commit 38e3339
Showing
5 changed files
with
45 additions
and
0 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,5 @@ | ||
SELECT al.Title, ar.Name, al.Genre, al.Released, al.CoverUrl | ||
FROM ARTISTS ar | ||
INNER JOIN ALBUMS al ON al.ArtistId = ar.Id | ||
WHERE ar.Name = 'The Beatles' | ||
ORDER BY al.Title 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT ar.Name | ||
FROM ARTISTS ar | ||
ORDER BY ar.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SELECT DISTINCT al.Title, ar.Name, t.Number, t.Title, strftime('%M:%S', (t.Duration / 1000), 'unixepoch') AS "Duration" | ||
FROM ARTISTS ar | ||
INNER JOIN ALBUMS al ON al.ArtistId = ar.Id | ||
INNER JOIN TRACKS t ON t.AlbumId = al.Id | ||
WHERE ar.Name = 'The Beatles' | ||
AND al.Title = 'The Beatles' | ||
ORDER BY t.Number 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 |
---|---|---|
@@ -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 ) = 0 | ||
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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 Genre, COUNT( DISTINCT ArtistId) AS "Artists", COUNT( DISTINCT Id ) AS "Albums", SUM( Tracks ) AS "Tracks", SUM( Price ) AS "Spend" | ||
FROM ALBUM_SUMMARY | ||
WHERE IsWishListItem = 0 | ||
GROUP BY Genre | ||
ORDER BY Genre ASC; |