title: Remove column from SELECT clause when using SUM in PostgreSQL
body: <p>I checked the <a href="https://stackoverflow.com/questions/45129912/postgresql-9-6-using-case-when-clause-based-on-sum-of-the-column">answer here</a> but didn't solve my problem because I even adding the <code>else</code> still throwing the same error:</p>
  <pre><code>ERROR:  column table1.column11 must appear in the GROUP BY clause or be used in an aggregate function
  </code></pre>
  <p>I would like to remove <code>table1.column11</code> from <code>SELECT</code> because is affecting the <code>GROUP BY</code>. Instead of each <code>ENUM</code> type be a column in a single line this query below is returning a table with a <code>ENUM</code> column filled in different lines.</p>
  <p>Query example:</p>
  <pre><code>SELECT table1.column11, -- enum column
     table2.id,
     (case when table1.column11 = 'enum_value_1' then SUM(table1.column12) end) as enum_value_1,
     (case when table1.column11 = 'enum_value_2' then SUM(table1.column12) end) as enum_value_2,
     --- ...
     (case when table1.column11 = 'enum_value_9' then SUM(table1.column19) end) as enum_value_9,
  FROM table1
  LEFT JOIN table2 ON table2.id = table1.table2_id
  WHERE table1.column13 IS NULL
  GROUP BY table2.id, table1.column11
  ORDER BY table2.id ASC
  </code></pre>
  <hr />
  <p>How is now:</p>
  <pre><code>table1.column11 | table2.id | enum_value_1 | enum_value_2 | ... | enum_value_9
  ================|===========|==============|==============|=====|=============
  enum_value_1    | 1         | 10           | [null]       | ... | [null]
  enum_value_2    | 1         | [null]       | 20           | ... | [null]
  ...             | ...       | ...          | ...          | ... | ...
  enum_value_9    | 1         | [null]       | [null]       | ... | 15
  </code></pre>
  <p>How I would like to have:</p>
  <pre><code>table2.id | enum_value_1 | enum_value_2 | ... | enum_value_9
  ==========|==============|==============|=====|=============
  1         | 10           | 20           | ... | 15
  </code></pre>