title: grouping every N values
body: <p>I have a table like this in PostgreSQL. I want to perform aggregation functions like mean and max for every 16 records based on ID (which is primary key). For example I have to calculate mean value for first 16 records and second 16 records and so on. </p>
  
  <pre><code>+-----+-------------
  | ID  |  rainfall  |
  +-----+----------- |
  |  1  |  110.2     |
  |  2  |  56.6      |
  |  3  |  65.6      |
  |  4  |  75.9      |
  +-----+------------
  </code></pre>