【问题标题】:MYSQL cumulative sum by date [duplicate]MYSQL按日期累积总和[重复]
【发布时间】:2018-08-09 09:58:57
【问题描述】:

如何进行累计?

我的查询是:

select dateb,ricetype,bajet1
from bajet
where ricetype='grand total'

我如何归档“新价值”?

【问题讨论】:

    标签: mysql


    【解决方案1】:

    你可以这样做:

    set @CumSum := 0;
    select dateb, ricetype, bajet1, (@CumSum := @CumSum + bajet1) as New_Value
    from bajet where ricetype='grand total';
    

    【讨论】:

    • 效果很好!非常感谢!
    猜你喜欢
    • 2014-04-12
    • 1970-01-01
    • 1970-01-01
    • 2021-06-09
    • 2020-04-03
    • 1970-01-01
    • 1970-01-01
    • 2018-03-02
    • 2019-09-27
    相关资源
    最近更新 更多