Sqlserver
 sql >> Base de données >  >> RDS >> Sqlserver

Comment obtenir le nombre de faux dans chaque colonne d'une table ?

Ceci :

SELECT SUM(CASE WHEN Col1 = 'false' THEN 1 ELSE 0 END) AS Col1
    , SUM(CASE WHEN Col2 = 'false' THEN 1 ELSE 0 END) AS Col2
    , SUM(CASE WHEN Col3 = 'false' THEN 1 ELSE 0 END) AS Col3
    , SUM(CASE WHEN Col4 = 'false' THEN 1 ELSE 0 END) AS Col4
    , SUM(CASE WHEN Col5 = 'false' THEN 1 ELSE 0 END) AS Col5
FROM T_myTable