Using COUNT in SQL Server doesn't show null values -
select songs number of playlists member of.
select title, count(*) 'number of playlists member of' song inner join playlistsong on playlistsong.songid = song.id inner join playlist on playlist.id = playlistsong.playlistid group song.title
this solution works, doesn't show songs not assigned playlist. there way include songs?
please let me know if need more information.
use left join
instead
select song.title, count(distinct playlist.id) 'number of playlists member of' song left join playlistsong on playlistsong.songid = song.id left join playlist on playlist.id = playlistsong.playlistid group song.title
Comments
Post a Comment