0

我正在使用类似于以下表格的表格:

PBName          InputDate     Amount

Michael Brown   07-jan-13     1391000,000 €
Mary Aspas      07-jan-13     -400000,000 €
Thomas Dand     15-feb-13     3000000,000 €
Mary Aspas      31-jul-13     3000000,000 €

然后,当 InputDate 早于给定日期时,我只是试图通过 PBName 获取总金额:

Dim dd As Date

dd = 15-feb-13

这是我正在使用的代码:

strSQL = "SELECT Rea.PBName, SUM(CASE WHEN Rea.InputDate < dd THEN Rea.AMOUNT / 1000000 ELSE 0 END) As NNARea " 

当我尝试运行查询时,我收到消息“列名无效”。

请你帮助我好吗?

谢谢

4

1 回答 1

0

这应该对你有用......

strSQL = "SELECT PBName, SUM(Amount)/1000000 AS NNARea " & _
         "FROM Rea " & _
         "WHERE InputDate < #" & dd & "# " & _
         "GROUP BY PBName;"
于 2013-09-26T16:16:22.970 回答