如何根据标题记录代码获得累积金额?
考虑:
tbl_A:
--------------------------------
| is_title | code | amount |
--------------------------------
| 1 | "1" | null |
| 0 | "11" | 10 |
| 0 | "12" | 15 |
| 1 | "13" | null |
| 0 | "131" | 3 |
| 0 | "132" | 3 |
| 1 | "2" | null |
| 0 | "21" | 30 |
| 0 | "22" | 40 |
--------------------------------
我想得到:
--------------------------------
| code | amount | cumulative |
--------------------------------
| "1" | null | 25 |
| "11" | 10 | null |
| "12" | 15 | null |
| "13" | null | 6 |
| "131" | 3 | null |
| "132 | 3 | null |
| "2" | null | 70 |
| "21" | 30 | null |
| "22" | 40 | null |
--------------------------------
我尝试在SELECT上对列进行别名并在嵌套SELECT的WHERE上使用它时失败。