title: Rolling average using date_trunc
body: <p>I’m using <code>date_trunc</code> to aggregate over a timestamp field. I'm trying to count the number of unique values in a given field, over a month. If I choose <code>month</code> as my resolution :</p>
  
  <pre><code>SELECT date_trunc('month', timestamp), COUNT(DISTINCT(foo)) FROM ...
  </code></pre>
  
  <p>then all resulting entries are at the beginning of each month, and so “2017-01-01" would be counting the unique entries where the <code>timestamp</code> field is anywhere in January. </p>
  
  <p>Is there a way to specify an offset such that I might have an entry at 2017-01-15, comprising entries up to 2017-02-15 ?</p>
  
  <p>Thanks.</p>