title: How to express this query in slick involving group by, having, count
body: <p>Suppose I have a table defined like this in Slick 3.2.3:</p>
  
  <pre><code>class ATable(tag: Tag) extends Table[(Int, Option[Boolean])](tag, "a_table") {
    def someInt = column[Int]("some_int")
    def someBool = column[Option[Boolean]]("some_bool")
    def * = (someInt, someBool)
  }
  object ATable extends TableQuery(new ATable(_))
  </code></pre>
  
  <p>and a bit of data to go with it:</p>
  
  <pre><code>insert into a_table
  values
  (1, true),
  (2, null),
  (2, true),
  (2, null),
  (3, true),
  (3, true),
  (3, null);
  </code></pre>
  
  <p>Now I'd like to find those ints in the table where there's exactly one row where <code>some_bool</code> is not <code>null</code>. This is not difficult in SQL:</p>
  
  <pre><code>select some_int
  from a_table
  group by some_int
  having count(some_bool) = 1;
  </code></pre>
  
  <p>This works just fine. So let's try it with Slick:</p>
  
  <pre><code>ATable
   .groupBy(_.someInt)
   .filter(_._2.map(_.someBool).countDefined === 1)
   .map(_._1)
  </code></pre>
  
  <p>And while this compiles, it will crash at runtime with the error message “<code>slick.SlickTreeException: Cannot convert node to SQL Comprehension</code>”. Is this a known limitation or a bug in slick? Or am I supposed to write my query in a different way?
  It's of course possible to write this with a subquery, but I'd rather understand why the <code>groupBy</code> thing doesn't work…</p>