Have you tested this query in regular SQL context if it works and if it returns what you expect of? Maybe you should think about adding a subquery to your sql request.
Correct syntax should by like:
select
case when Result = 'OK' then count(Result) end as CountResult
from ...
group by Result