title: sum last n days quantity using sql window function
body: <p>I am trying to create following logic in Alteryx and data is coming from Exasol database.</p>
  <p>Column “Sum_Qty_28_days“ should sum up the values of “Qty ” column for same article which falls under last 28 days.</p>
  <p>My sample data looks like:</p>
  <p><a href="https://i.stack.imgur.com/PSaxQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PSaxQ.png" alt="enter image description here" /></a></p>
  <p>and I want following output:</p>
  <p><a href="https://i.stack.imgur.com/dAoPQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dAoPQ.png" alt="enter image description here" /></a></p>
  <p>E.g. “Sum_Qty_28_days” value for “article” = ‘A’ and date = ‘’2019-10-8” is 8 because it is summing up the “Qty” values associated with dates (coming within previous 28 days) Which are:
  2019-09-15
  2019-10-05
  2019-10-08
  for “article” = ‘A’.</p>
  <p>Is this possible using SQL window function?
  I tried myself with following code:</p>
  <pre><code>SUM(&quot;Qty&quot;) OVER (PARTITION BY &quot;article&quot;, date_trunc('month',&quot;Date&quot;)
               ORDER BY &quot;Date&quot;)
  </code></pre>
  <p>But, it is far from what I need. It is summing up the Qty for dates falling in same month. However, I need to sum of Qty for last 28 days.</p>
  <p>Thanks in advance.</p>