Get cumulated sum in SQL

To compute the cumulated sum (running total) in SQL, use SUM(metric) OVER (ORDER BY dimension).
You can also get the running total partitioned by a group, with PARTITION BY, as described below:

-- Get Google Analytics sample data for July 2017
WITH sub1 AS (
      SELECT PARSE_DATE("%Y%m%d", date) AS day,
             EXTRACT(WEEK FROM PARSE_DATE("%Y%m%d", date)) AS week,
             SUM(totals.visits) AS sessions
        FROM `bigquery-public-data.google_analytics_sample.ga_sessions_201707*` 
    GROUP BY 1,2
)

  SELECT day,
         sessions,
         -- Cumulated sum of daily sessions
         SUM(sessions) OVER (ORDER BY day) AS sessions_cumtd,
         week,
         -- Cumulated sum of sessions, partitioned by week
         SUM(sessions) OVER (PARTITION BY week ORDER BY day) AS sessions_cumtd_week
    FROM sub1
ORDER BY day
| day        | sessions | sessions_cumtd | week | sessions_cumtd_week |
|------------|----------|----------------|------|---------------------|
| 2017-07-01 | 2048     | 2048           | 26   | 2048                |
| 2017-07-02 | 1895     | 3943           | 27   | 1895                |
| 2017-07-03 | 2046     | 5989           | 27   | 3941                |
| 2017-07-04 | 1938     | 7927           | 27   | 5879                |
| 2017-07-05 | 2885     | 10812          | 27   | 8764                |
| 2017-07-06 | 2658     | 13470          | 27   | 11422               |
| 2017-07-07 | 2450     | 15920          | 27   | 13872               |
| 2017-07-08 | 1859     | 17779          | 27   | 15731               |
| 2017-07-09 | 1921     | 19700          | 28   | 1921                |
| 2017-07-10 | 2769     | 22469          | 28   | 4690                |
| 2017-07-11 | 2635     | 25104          | 28   | 7325                |
| 2017-07-12 | 2554     | 27658          | 28   | 9879                |
| 2017-07-13 | 2741     | 30399          | 28   | 12620               |
| 2017-07-14 | 2382     | 32781          | 28   | 15002               |
| 2017-07-15 | 1721     | 34502          | 28   | 16723               |
| 2017-07-16 | 1766     | 36268          | 29   | 1766                |
| 2017-07-17 | 2671     | 38939          | 29   | 4437                |
| 2017-07-18 | 2804     | 41743          | 29   | 7241                |
| 2017-07-19 | 2514     | 44257          | 29   | 9755                |
| 2017-07-20 | 2668     | 46925          | 29   | 12423               |
| 2017-07-21 | 2427     | 49352          | 29   | 14850               |
| 2017-07-22 | 1724     | 51076          | 29   | 16574               |
| 2017-07-23 | 1966     | 53042          | 30   | 1966                |
| 2017-07-24 | 2436     | 55478          | 30   | 4402                |
| 2017-07-25 | 2631     | 58109          | 30   | 7033                |
| 2017-07-26 | 2725     | 60834          | 30   | 9758                |
| 2017-07-27 | 2529     | 63363          | 30   | 12287               |
| 2017-07-28 | 2433     | 65796          | 30   | 14720               |
| 2017-07-29 | 1597     | 67393          | 30   | 16317               |
| 2017-07-30 | 1799     | 69192          | 31   | 1799                |
| 2017-07-31 | 2620     | 71812          | 31   | 4419                |