Lets say I have table with 1 column like this:
Col A
1
0
0
1
If I SUM it, then I will get this:
Col A
2
My question is: how do I multiply Col A so I get the following?
Col A
0
I found a similar answer but not one that works for a list of 1s and 0s because it’s using the log() function:
SELECT ROUND(EXP(SUM(LOG([Col A]))),1)
FROM yourtable
2
Answers
Assuming that the A column really only contains 0 and 1, then we can simply check for the presence of at least one 0. If found, the product is 0, otherwise it is 1.
If allowed values are only 0 and 1 then BITAND_AGG could be used: