title: How to make an equality test on an array
body: <p>I am trying to aggregate values on an ID. I return them if they are all the same, but have to create another value 'C' if both are encountered. </p>
  
  <blockquote>
  <pre><code>CREATE TABLE foo (
      fooid int,
      foocomm text
  ); 
  
  INSERT INTO foo (fooid,foocomm)
  VALUES (1,'A'); 
  INSERT INTO foo (fooid,foocomm)
  VALUES (1,'B'); 
  INSERT INTO foo (fooid,foocomm)
  VALUES (2,'A');
  </code></pre>
  </blockquote>
  
  <pre><code>SELECT 
    CASE 
  
      WHEN array_remove(array_agg(foocomm),NULL) = {'A'} THEN 'A'
      WHEN array_remove(array_agg(foocomm),NULL) = {'B'} THEN 'B'
      WHEN array_remove(array_agg(foocomm),NULL) = {'A','B'} THEN 'C'
    END AS BAR
  
  FROM foo
  GROUP BY fooid;
  </code></pre>
  
  <p>It should yield</p>
  
  <pre><code>fooid,foocomm
  1, 'C'
  2, 'A'
  </code></pre>