How can I count more than one column with a where clause? (SQL)


I have the following query:

    SELECT count(Committees)
    FROM [Annual Questionnaire]
    WHERE Committees=TRUE;

However, I'd like to include other columns in the result e.g. Insurance, Equalities and counted where the value is True e.g. Insurance=True. Not all the columns in the table have to be counted.

I think a pseudo query would be:

SELECT count(Committees),
FROM [Annual Questionnaire]
WHERE Committees=TRUE
  AND Insurance=TRUE;

^ This doesn't work because it selects rows where only Committees and Insurance is True

Basically, how do I count the specified columns where the value is True?

you can do something like

    SUM(IIF(Committees=True, 1, 0))
    , SUM(IIF(Insurance=True, 1, 0))
FROM [Annual Questionnaire]