SET @csum := 0;
SELECT col, (@csum := @csum + col) AS cumulative_sum FROM tbl;
해당 col 값을 순차적으로 누적 합산을 볼수 있다.
col | cumulative_sum |
1 | 1 |
1 | 2 |
1 | 3 |
1 | 4 |
SET @csum := 0;
SELECT col, (@csum := @csum + col) AS cumulative_sum FROM tbl;
해당 col 값을 순차적으로 누적 합산을 볼수 있다.
col | cumulative_sum |
1 | 1 |
1 | 2 |
1 | 3 |
1 | 4 |
댓글