title: Find Previous Month MTD (Month to Date) Calculation in BigQuery
body: <p>Assuming I have initial table of date and each order value of the date:</p>
  <pre><code>date_order  |gross_order|
  |---------- |-----------|
  |25 Nov     | 50        |
  |27 Nov     |300        |
  |26 Dec     | 400       |
  |29 Dec     |300        |
  |30 Dec     |100        |
  </code></pre>
  <p>So I use this query for calculating current MTD (cumulative gross order in a month from day 1 of certain month to certain date in that month),</p>
  <pre><code>select date_order, gross_order, sum(gross_order) OVER (PARTITION date_trunc(date_order,MONTH ORDER BY date_order) AS current_mtd
  </code></pre>
  <p>the result will be something like this:</p>
  <pre><code>|date_order |gross_order| current_mtd |
  |---------- |-----------|-------------|
  |25 Nov     | 50        | 50          |
  |27 Nov     |300        |350          |
  |26 Dec     | 400       |400          |
  |29 Dec     |300        |700          |
  |30 Dec     |100        |800          |
  </code></pre>
  <p>The idea is to also have value of previous month MTD value for all row in the date range, so in the 25 and 27 Nov, previous MTD value will be 0 because there are no prior gross order value. And in the 30 december row, the value will be sum of gross_order between 1 to 30 november, which give us 50 + 350 = 400</p>
  <p>Expected result:</p>
  <pre><code>|date_order |gross_order| current_mtd | previous_mtd
  |---------- |-----------|-------------|-------------|
  |25 Nov     | 50        | 50          |0            |
  |27 Nov     |300        |350          |0            |
  |26 Dec     | 400       |400          |50           |
  |29 Dec     |300        |700          |350         |
  |30 Dec     |100        |800          |350         |
  </code></pre>
  <p>I'm kinda stuck as how to calculate the previous mtd value, is there any way to do it? Thank you</p>