title: Retrieve all distinct values in one column that satisfies combination of condition in other column (SQL)
body: <p>I have a table like so:</p>
  
  <pre><code>+-----------------+-----------------+
  +        x        +        y        +
  +-----------------+-----------------+
  +        a        +        1        +
  +        a        +        2        +
  +        b        +        1        +
  +        b        +        3        +
  +        c        +        1        +
  +        c        +        2        +
  +        c        +        3        +
  +-----------------+-----------------+
  </code></pre>
  
  <p>Say I want to find all the distinct rows in x that contain a desired combination of values in y <strong>per group</strong>. </p>
  
  <p>Say the condition is to find all groups where <code>y = [1,2]</code>. This would yield <code>a</code> and <code>c</code>.</p>
  
  <p>Note that the solution needs to scale to any number of combinations in y, for instance <code>y = [1,2,3]</code> which would yield <code>c</code>.</p>