How to check that a value exists in the group, and the other isn't?
<p>I want to check if one value of column exist in group and other isn't. My table looks like this:</p>

<pre><code>num | text | 
 1  |    A | 
 1  |    B | 
 2  |    A | 
 2  |    C | 
 3  |    A | 
 3  |    D | 
 4  |    B | 
 4  |    C | 
</code></pre>

<p>I want to get groups with 2,3 num.Now I use this query:</p>

<pre><code>select c1.num from table c1 inner join table c2 on c1.num =  c2.num
where c2.text !='B' and c1.type !='B'
group by c1.num, c1.text
having(c1.text='A');
</code></pre>