Last active
December 24, 2015 02:19
-
-
Save williamjacksn/6729374 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
WITH | |
rated_songs AS ( | |
SELECT song_rating_id | |
FROM rw_songratings | |
WHERE user_id = %s), | |
unrated_songs AS ( | |
SELECT song_id, album_id, song_available, song_releasetime | |
FROM rw_songs | |
WHERE song_verified AND sid = %s AND song_rating_id NOT IN ( | |
SELECT song_rating_id FROM rated_songs)), | |
album_unrated_counts AS ( | |
SELECT album_id, COUNT(song_id) AS unrated_songs_in_album | |
FROM rw_songs | |
WHERE song_id IN ( | |
SELECT song_id FROM unrated_songs) | |
GROUP BY album_id) | |
SELECT song_id, album_id, song_available, song_releasetime, unrated_songs_in_album | |
FROM unrated_songs | |
JOIN album_unrated_counts USING (album_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment