出于某种原因,在 Access 2010 中使用分组依据的选择查询中使用日期/时间字段会中断(记录未正确“按”文本字段首先“分组”,多次显示相同的“aTextField”值)。我能够在一个简单的表查询中复制该问题。前任:
SELECT aTextField, SUM(aIntField) AS SumOfaIntField
FROM simpleTable
GROUP BY aTextField, aDateField
HAVING aDateField >= Date()
ORDER BY aTextField;
一旦您从查询中删除“aDateField”(分组依据和有行),它就会正常工作。我什至可以删除 HAVING 行,它仍然会中断。让我相信这是 Group By 的事情。
任何反馈都会很棒。谢谢!
编辑更多细节
**simpleTable**
--------------------------------------------
| ID | aTextField | aIntField | aDateField |
============================================
| 1 | John Doe | 1 | 3/14/2013 |
| 2 | John Doe | | 3/15/2013 |
| 3 | Jane Doe | 1 | 3/15/2013 |
| 4 | John Doe | 2 | 3/18/2013 |
| 5 | Jane Doe | 1 | 3/19/2013 |
| 6 | John Doe | | 3/20/2013 |
| 7 | John Doe | 3 | 3/21/2013 |
| 8 | Jane Doe | 1 | 3/19/2013 |
| 9 | John Doe | | 3/22/2013 |
| 10 | Jane Doe | 2 | 3/20/2013 |
| 11 | Jane Doe | | 3/21/2013 |
| 12 | Jane Doe | | 3/22/2013 |
--------------------------------------------
**Expected Result**
-------------------------------
| aTextField | SumOfaIntField |
===============================
| Jane Doe | 4 |
| John Doe | 3 |
-------------------------------
**Actual Result**
-------------------------------
| aTextField | SumOfaIntField |
===============================
| Jane Doe | 2 |
| Jane Doe | 2 |
| Jane Doe | |
| Jane Doe | |
| John Doe | |
| John Doe | 3 |
| John Doe | |
-------------------------------
因此,似乎正在发生的是每个日期也有单独的一行。我只需要按日期过滤,而不必按它分组。但是,Access 不会接受不分组的查询。选项?