Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

Wie bekomme ich die Anzahl der falschen in jeder Spalte einer Tabelle?

Dies:

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