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

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -