CrossTab将空值转换为“0”

时间:2014-07-21 16:27:19

标签: sql ms-access report crosstab

我需要让CrossTab将零计数替换为零,以便在没有数据时我的报告将具有正确的总计。

我被告知要将Nz()函数放在SQL中,但我很难确定将其更改为COUNT([Traffic Report Totals - Query].TrafficTypeName)以将Null值替换为0的位置。

我在下面包含了完整的SQL:

PARAMETERS [Forms]![Report Date Range]![txtStart] DateTime, [Forms]![Report Date Range]![txtEnd] DateTime;
TRANSFORM Count([Traffic Report Totals - Query].TrafficTypeName) AS CountOfTrafficTypeName
SELECT [Traffic Report Totals - Query].CommunityGroup, [Traffic Report Totals - Query].Date
FROM [Traffic Report Totals - Query] LEFT JOIN [Contract Budget] ON [Traffic Report Totals - Query].CommunityGroup = [Contract Budget].CommunityGroup
GROUP BY [Traffic Report Totals - Query].CommunityGroup, [Traffic Report Totals - Query].Date
PIVOT [Traffic Report Totals - Query].TrafficTypeName In ("A-Initial Realtor Showing","A-Initial Visit","B-Be Back","C-Additional Contract Paperwork","C-Cancellation","C-Closing","C-Contract","C-Contract Deposit","C-Final Orientation","Completion","C-Pre-Contruction Meeting","C-Pre-Drywall Walk","C-Realtor Showing","C-WJH Showing","Email Followup","Email Inquiry","Realtor Call","Realtor Visit","Telephone Follow-Up","Telephone Inquiry","Warranty Call");

1 个答案:

答案 0 :(得分:0)

您需要将查询中的计数字段包装在示例中流量报告总计 - 查询中的数据来源。转到Query的SQL,然后检查字段并将它们包装在Nz()函数中。