how to get count(col1), count(col2), count(sol3) with only one query

M

Mario Krsnic

Hallo everybody!
I have in a table three columns with boolean values. So I can get the number
in a column:
SELECT count(col1)
FROM tbl where col1=true

Is it possible to get count(col1), count(col2), count(sol3) with only one
query? In every
column should be considered only true values (col1=true, col2=true,
col3=true)
Thanks for your ideas!
Mario
 
A

Allen Browne

If these are yes/no fields, sum them.

Access uses -1 for True, and 0 for False.
The sum is therefore the count if you ignore the sign.

This kind of thing:
SELECT -Sum(Col1) AS SumOfCol1, -Sum(Col2) AS SumOfCol2,
FROM tbl;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top