我有一个表 a_daily 有像这样的列
1.date
2.FromDate
3.Target
4.Cumulative_Target
我将每天添加行,因此每天参考 fromdate 和 date Cumulative_Target 列将更新,如表中所示
这是我需要做的:
    date                Fromdate      Target          Cumulative_Target
    2012-04-16    2012-04-16    500              500                  '(cycle1-started)
    2012-04-17    2012-04-16    500              1000    
    2012-04-18    2012-04-16    800              1800 
    '
    '
    '
    2012-05-15   2012-04-16     200             xxxxxx                 '(cycle1-completed)
    2012-05-16   2012-05-16     150             150                     '(cycle2-started)
    2012-05-17   2012-05-16     100             250
    2012-05-18   2012-05-16     700             950
    '
    '
    '
    '
    2012-06-15  2012-06-15      200             xxxxx                    '(Cycle2-completed)
所以表中的起始日期将在每个周期内变化
我用于更新的查询是:
UPDATE a_daily 
SET a_daily.Cumulative_Generation = sum(a_daily.Target) 
    between a_daily.Date and a_daily.From_Date
我不知道如何化妆计算列请帮助我!