title: Query Optimisation: SUMIF and CASE WHEN
body: <p>I am writing a query to pull the number of rewarded ads. To do so, I have to sum &quot;rewarded_ad&quot; events from event_name. Then, I am cleaning up null values in a second statement. So currently, my query includes a subquery. However, is there a way to do this without utilising a subquery? I am looking to optimise this process.</p>
  <p>My subquery includes:</p>
  <pre><code>SUM(IF(LOWER(event_name)= 'rewarded_ad', 1,0)) AS rewarded_ad
  </code></pre>
  <p>The outside query includes:</p>
  <pre><code>CASE WHEN rewarded_ad IS NULL THEN 0 ELSE rewarded_ad END AS rv_count
  </code></pre>
  <p>Any help is appreciated. Thank you in advance.</p>