title: postgreSQL 1 minute average of values
body: <p>I need to query from my database (postgreSQL) the value average of 1 minute.</p>
  
  <p>The database is recorded in milliseconds and looks like this:</p>
  
  <pre><code>timestamp | value
  ------------------
  1528029265001 | 123
  1528029265020 | 232
  1528029265025 | 332
  1528029265029 | 511
  ...           | ...
  1528029265176 | 231
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>SELECT   
        avg(value), 
        extract(minutes FROM to_timestamp(timestamp/1000)) as one_min
  FROM table GROUP BY one_min
  </code></pre>
  
  <p>But it seems to be stuck in querying.</p>
  
  <p>I'm sure there is a super easy way to do it.
  Any suggestions?</p>