【发布时间】:2021-12-09 04:49:30
【问题描述】:
我有一个非常棘手的 SQL 问题,也许是我遇到过的最棘手的问题 假设我在下面有一张桌子
调用 table_1
| Date | spend |
|---|---|
| Oct. 20 | 50 |
| Oct. 19 | 40 |
| Oct. 18 | 50 |
| Oct. 17 | 60 |
| Oct. 16 | 50 |
现在我需要另一个表格来汇总我之前的所有支出,并包括每个日期。喜欢展示我迄今为止在每个日期花费的每一笔钱。
对于每个日期。
下面是我要计算的表
调用 table_2
| Date | spent |
|---|---|
| Oct. 20 | 250 ( sum of all the spend before and includes Oct.20) |
| Oct. 19 | 200 ( sum of all the spend before and includes Oct.19) |
| Oct. 18 | 160 ( sum of all the spend before and includes Oct.18) |
| Oct. 17 | 110 ( sum of all the spend before and includes Oct.17) |
| Oct. 16 | 50 ( sum of all the spend before and includes Oct.16) |
我已经尝试在 date_1
不工作。
有人可以给我一个提示吗?
【问题讨论】: