title: SQL "all in" group by
body: <p>I'm having troubles with some sql statement.</p>
  
  <p>I have a table like this:</p>
  
  <p><a href="https://i.stack.imgur.com/B2sTW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B2sTW.png" alt="Table"></a></p>
  
  <p>I couldn't find any SQL form to do that but I want something like this:</p>
  
  <pre><code>SELECT 
     Col1, 
     CASE WHEN all(Col2 in ('A','B','C') THEN "auto"
          ELSE distinct Col2 not in ('A','B','C')        as Col2
  FROM mytable
  GROUP BY Col1
  </code></pre>
  
  <p>Obviously the query is not valid SQL, so I explain what I want here:
  If all registers in a group are A, B or C I want the column value to be "AUTO", in the other hand, if there is any column value different than A,B or C I want that to be selected.</p>
  
  <p>So the result would have to be:</p>
  
  <pre><code>Col1   Col2
  1      AUTO
  2      R
  </code></pre>