title: Categorising "group by" groups by their contents
body: <p>I have a view which is a product of two joined tables:</p>
  
  <pre><code>ID Type
  1   A
  2   A
  2   B
  3   B
  </code></pre>
  
  <p>There can only be two values in Type column: A or B.</p>
  
  <p>I would like to aggregate IDs into three categories: Catgegory_A, Category_B and Category_AB. If the ID is associated only with type A, it is assigned Category_A, if the ID is associated with types A and B it is associated with Categry_AB. Based on these rules, the view above should be categorised as follows:</p>
  
  <pre><code>ID  Category
  1  Category_A
  2  Category_AB
  3  Category_C
  </code></pre>
  
  <p>Is it possible to write an SQL query to achieve this?</p>