Boolean filters and conditional counts
Separate literal codes, truth conversion, counted branches and zero fallback.
Why does an inactive urgent item pass the active-work filter?
Group the alternatives before applying the shared condition.
Why does WHERE kind=1 OR 2 include every kind?
Use a comparison list rather than a standalone true numeric literal.
Why does a yes flag fail while the text 1 passes?
Compare the declared textual truth code explicitly.
Why does COUNT count the zero branch of a condition?
Return NULL outside the counted condition instead of numeric zero.
Why does a valid zero reading switch to its backup?
Use NULL-only fallback when zero is a real observation.