访问:DSUM表现得很奇怪

时间:2018-05-27 15:57:08

标签: ms-access-2010

我正在尝试使用访问2010查询和DSUM函数计算运行总和 数据是:
表cumulvsce_2
COquille / Date / 1ere显示
0/07/03/201/1
0/16/03/201/1
0/19/03/201/1
0/22/03/201/1
0/28/03/201/0
0/29/03/201/1
0/30/03/201/0
0/31/03/201/0

目标是为每个日期计算“1ere application”的运行总和

查询是:

  SELECT CumulVSCE_2.COQUILLE, CumulVSCE_2.Date, CumulVSCE_2.[1ere apparition], DSum([cumulvsce_2]![1ere apparition],"CumulVSCE_2","[date]<=" & [date]) AS Expr1 INTO CumulVSCE_3b
    FROM CumulVSCE_2
    GROUP BY CumulVSCE_2.COQUILLE, CumulVSCE_2.Date, CumulVSCE_2.[1ere apparition];

结果是:
COQUILLE / Date / 1ere apparition / Expr1
0/07/03/201 / 1/1
0/16/03/2011/1/2 0/19/03/2011/1/3
0/22/03/2011/1/4
0/28/03/201/0/0 0 0/29/03/201/1/6
0/30/03/201/0/0 0 0/31/03/201/0/0 0

这很奇怪,因为28/10/2018的值应为4(1 + 1 + 1 + 1 + 0),39,30和31/3的值应为5(1 + 1 + 1 + 1 + 0 + 1; 1 + 1 + 1 + 1 + 0 + 1 + 0; 1 + 1 + 1 + 1 + 0 + 1; + 0 + 0)

知道公式有什么问题吗?

DSum([cumulvsce_2]![1ere apparition],"CumulVSCE_2","[date]<=" & [date])

1 个答案:

答案 0 :(得分:0)

尝试正确格式化日期值:

DSum("[1ere apparition]","CumulVSCE_2","[date] <= #" & Format([date], "yyyy\/mm\/dd") & "#")