I have a column that has a value that is either 0 or 1. how do i count the numbers of zeros?
SELECT A.id
FROM table1 A
GROUP BY A.id
HAVING SUM(A.zeroorone) >=
ALL (SELECT SUM(AA.zeroorone)
FROM table1 AA
GROUP BY AA.id)
I know this counts the number of ones. I cant seem to get it
A CASE statement would do nicely:
SELECT SUM(CASE WHEN zeroorone = 0
THEN 1
ELSE 0 END) AS TOTAL_ZEROS
FROM table1
Using count...
SELECT COUNT(*) FROM table1
WHERE zeroone=0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With