如何分组总计

时间:2017-05-09 09:21:34

标签: sql ms-access access-vba ms-access-2010

我正在尝试按类别分组 - 但我正在使用的SQL是按日期对它们进行分组。

实施例: 如果用户选择日期范围01/04/17 - 20/04/17,它将显示在A类下找到的总数

实际发生了什么: 结果显示A类10次,并显示每个日期的总数而不是完整的分组总数

希望这是有道理的

    SELECT tbl_ComplaintsCoded.CauseManager, Count(tbl_ComplaintsCoded.CauseManager) AS CountOfCauseManager, tbl_ComplaintsCoded.[Account Number], tbl_ComplaintsCoded.TouchCSM, tbl_ComplaintsCoded.[Mail Date]
FROM tbl_ComplaintsCoded
GROUP BY tbl_ComplaintsCoded.CauseManager, tbl_ComplaintsCoded.[Account Number], tbl_ComplaintsCoded.TouchCSM, tbl_ComplaintsCoded.[Mail Date]
HAVING (((tbl_ComplaintsCoded.TouchCSM)=[Forms]![frm_Central_Reporting]![Combo209]) AND ((tbl_ComplaintsCoded.[Mail Date]) Between [Forms]![frm_Central_Reporting]![Text204] And [Forms]![frm_Central_Reporting]![Text206]));

1 个答案:

答案 0 :(得分:1)

这应该得到你想要的东西:

'btn-2'

另外,请阅读:WHERE vs HAVING