Select all songs together with the number of playlists they are member of.
Select
Title, Count(*) as 'number of playlists they are member of'
from
Song
inner join
PlaylistSong on PlaylistSong.songID = Song.ID
inner join
Playlist on Playlist.ID = playlistsong.PlayListID
group by
Song.title
This solution almost works, but it doesn't show songs that are not assigned to any playlist. Are there any way to include those songs?
Please let me know if you need more information.
COUNT(*) AS 'alias'), and is already not supported in Azure. Use<expression> AS [Alias]or[Alias] = <expression>to avoid compatibility problems with future versions of SQL Server. A good article on this is Bad Habits to Kick : Using AS instead of = for column aliases