How to get sum of one day and sum of last three days in single query?
<p>Suppose I have a statistical table like this:</p>

<pre><code>date | stats
-------------
10/1 | 2
10/1 | 3
10/1 | 2
10/2 | 1
10/3 | 3
10/3 | 2
10/4 | 1
10/4 | 1
</code></pre>

<p>What I want is three columns:</p>

<ol>
<li>Date</li>
<li>sum(stats) of Date</li>
<li>sum(stats) of last three days before Date</li>
</ol>

<p>I know I can use window function to handle the 2nd column, but I cannot handle 2nd and 3rd at the same time.</p>

<p>What should I do to archive this?</p>

<p>Thanks!</p>