title: How to do a rolling sum in BigQuery for groups of weeks?
body: <p>I have the following table, which contains two columns: date and total_visits (website visits). I need to compute two new variables (rolling sums).</p>
  <ol>
  <li><p>Column_A: A rolling sum for each day. For each day, I have to present the sum of the total visits from the last 14 days (without considering the current day). Of course, the first 14 days in this table can not have this value due to the fact there are not enough previous days to compute this value.</p>
  </li>
  <li><p>Column_B: A rolling sum for each day. For each day, I have to present the sum of the total visits considering the days between 4 weeks and 2 weeks before the current day. This means, for example, for 2019-01-29, the value we should be seeing is the sum of the total visits between 2021-01-01 and 2021-01-14. Of course, the first 28 days in the table won't have values for this column due to the fact there are no enough data to compute the value.</p>
  </li>
  </ol>
  <p>The next table is an example:</p>
  <p><a href="https://i.stack.imgur.com/SycWH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SycWH.png" alt="enter image description here" /></a></p>
  <p>I currently have a solution in SQL (Workbench), but I need to apply this for a database store in GCP and there are syntax differences that I have not been able to understand. Any hint? Thanks in advance</p>