title: sql conditional sum statement
body: <p>The sql conditional sum statement below keeps throwing me an error and I'm not sure why.
  The logic should create a flag when any of the underlying flags are 1, thus the sum &gt;=1.</p>
  <pre><code>Error message: mismatched nput '(' expecting &lt;EOF&gt;
  </code></pre>
  <pre><code>,case when (sum(case when (TAB_flag = 1) OR
  (TOP_SPOT_flag = 1) OR
  (PAGE_flag = 1) OR
  (DOWNLOAD_flag = 1) &gt;= 1)) THEN 1 ELSE 0 END AS any_p_flag
  </code></pre>