title: Postgres sum of values one per unique id
body: <p>I have to get a sum of the values from the column2, but I should calculate it only once per id. 
  For example for the table below I need 5 + 10 + 7 and not 5 + 5 + 10 + 7</p>
  
  <pre><code>id column1 column2
  1  value1  5
  1  value1  5
  2  value1  10
  3  value1  7
  </code></pre>
  
  <p>The latter I get by the following query, but I don't know how to adapt it to get the first sum. Should I filter the table beforehand like selecting all the distinct rows?</p>
  
  <pre><code>SELECT column1, sum(column2) FROM table group by column1;
  </code></pre>