Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Raggruppa per valori null e non null

puoi farlo facilmente per caso :

SELECT SUM(CASE WHEN FACEBOOKID IS NULL THEN 1 ELSE 0 END) AS NbUsers , 'NO' AS FACEBOOK
FROM USERTABLE
UNION ALL 
SELECT SUM(CASE WHEN FACEBOOKID IS NULL THEN 0 ELSE 1 END) AS NbUsers , 'YES' AS FACEBOOK
FROM USERTABLE