mysql - MYSQL 按日期累计总和
问题描述
我怎样才能做累积和?
我的查询是:
select dateb,ricetype,bajet1
from bajet
where ricetype='grand total'
我如何归档“新价值”?
解决方案
你可以这样做:
set @CumSum := 0;
select dateb, ricetype, bajet1, (@CumSum := @CumSum + bajet1) as New_Value
from bajet where ricetype='grand total';
推荐阅读
- excel - Visual Basic for Applications 对象问题
- docker - 连接到远程 Docker 守护进程
- c++ - 不能在 QOpenGLBuffer::allocate 上使用 std::vector 代替 std::array
- python - 下面的递归函数是如何工作的?
- html - 表单数据提交时如何从地址添加到邮箱?
- javascript - 使用 JS 在 Wordpress 中查看特定帖子时如何创建 cookie
- java - 找不到JDK文件?(苹果电脑)
- tcl - TCL:打开一个文件并返回一个包含注释和空行的非空行列表
- swift - SwiftUI - 如何更改嵌套在表单中的选取器的复选标记颜色
- video - 如何使用 ionic4 添加视频通话功能