我想通过mysql查询实现
+------+---------+
| frq | -any- |
+------+---------+
| 10 | 10 |
| 15 |10+15=25 |
| 15 |25+15=40 |
+------+---------+
请帮助代码参考,谢谢
答案 0 :(得分:12)
SELECT a.frq, sum(b.frq)
FROM table a
JOIN table b ON a.id >= b.id
GROUP BY a.frq
答案 1 :(得分:12)
MySQL论坛帮助了我!!!
mysql> set @my_var=0;
mysql> select frq, @my_var:=@my_var+frq as commutative_sum from `mytable`
这适用于我的mysql例程。