title: GROUP BY Create group if at least one value in group meets condition
body: <p>How to create group if at least one value in group meets condition?</p>
  
  <p>Here is an example of DB table <code>test</code>:</p>
  
  <pre><code>| ID | TYPE | COLOR |
  |====|======|=======|
  |  1 |    1 |     R |
  |  2 |    1 |     B |
  |  3 |    1 |     G |
  |  4 |    2 |     B |
  |  5 |    2 |     G |
  |  6 |    3 |     G |
  </code></pre>
  
  <p>I need to select all <code>TYPE</code> values that have more than one row, and at least one of COLORs is G for that TYPE.</p>
  
  <p>So pseudo-select would look like this:</p>
  
  <pre><code>  select TYPE 
      from test
  group by TYPE
    having count(*) &gt; 1
       and count(COLOR = 'G') &gt; 0
  </code></pre>