title: Conditional sum in slick (scala)
body: <p>I'm trying to rewrite following SQL into slick:</p>
  
  <pre><code>SELECT id
  SUM(
   if (spend &gt; 0, 1, 0)
  )
  FROM items
  GROUP by id
  </code></pre>
  
  <p>My current code looks similar to this:</p>
  
  <pre><code>items.groupBy(r =&gt; r.id).map {
    case (id, group) =&gt; (id, group.map { r =&gt; if (r.spend &gt; 0) 1 else 0 }.sum)
  }
  </code></pre>
  
  <p>But I got following error:</p>
  
  <p><code>polymorphic expression cannot be instantiated to expected type;
   found   : [R]slick.lifted.Rep[R]
   required: Boolean</code></p>
  
  <p>I also tried to use <code>filter</code> and <code>length</code>, but with no success. How can I achieve my goal?</p>