In Presto, we support the popular but non-standard IF construct as a shorthand for CASE, so you can do this: sum(if(bar, foo))
We also have a count_if() function: count_if(bar)
http://prestodb.io/docs/current/functions/conditional.html#i...
http://prestodb.io/docs/current/functions/aggregate.html#cou...