title: How can I do some kind of upsert within Postgres 9.5
body: <p>I have a simple table:</p>
  
  <pre><code>NAME    | TIMESTAMP | AMOUNT
  --------------------------
  Name1   | 123       | 1
  Name2   | 123       | 15
  Name3   | 124       | 3
  Name4   | 125       | 1
  </code></pre>
  
  <p>And so on.
  Now I get a new record. If the name and the timestamp is equal, I want the amount to be increased by the amount of the new record, otherwise the new record should be inserted.</p>
  
  <p>Something like:</p>
  
  <pre><code>INSERT INTO test.data (NAME, TIMESTAMP, AMOUNT) values ('Name1', 123, 4) 
  IF not EXIST; OTHERWISE UPDATE test.data set AMOUNT + NEWAMOUNT where TIMESTAMP = oldTimestamp and NAME = oldName
  </code></pre>
  
  <p>Is this somehow possible with one simple sql query using Postgres  9.5?</p>
  
  <p>Thanks</p>