select count(case when t1.a = 1 then foo else null end) as A_COUNT , count(case when t1.b = 2 then foo else null end) as B_COUNT from t1 where t1.a = 1 or t1.b = 2
If the sentence is not necessarily strict, but can help in productivity. Furthermore, "else null" is implicit when the else clause is omitted so you can safely leave it as well.
Noah yetter
source share