使用 Excel 2007,我使用 Data>From Access 按钮链接到 Access 查询,并将其设置为显示为表格。除了“安置费”类型的行之外,所有行都存在。
例如,在下面的示例中,Excel 表格中显示了免费案例填写扣除额,但没有显示安置费扣除额。此查询从 Access 导出为 Excel 格式,因此似乎是 Excel 在链接到它时忽略了这些行。
有什么想法会导致在链接到 Access 查询时忽略行?
Chain Account Distributor Warehouse StoreID USDate Type of Deduction TotalValue
Bob's Shops Bob's Shops SMITHS Romeoville KH00463 5/1/2012 Free Case Fill 29.8
Bob's Shops Bob's Shops SMITHS Romeoville KH00463 5/1/2012 Placement fee 2.98
Bob's Shops Bob's Shops JONES Greenwood UN20521 6/1/2011 Free Case Fill 38.81
-编辑-
SQL 如下 - 大约有四到五个堆叠查询,直到它下降到表级别。
安置费是单独计算的,然后直接从扣除表中添加到其余的扣除中,所以我唯一能想到的是它们的格式略有不同,Excel 忽略它们可能是因为值不一样数字类型作为其他扣除?但是,当我直接从 Access 导出查询时,一切看起来都像同一类型(即所有值都右对齐,因为它们被视为数字)。
SELECT Chain, Account, Distributor, Warehouse, StoreID, USDate, [Type of Deduction], SUM([Total Value($)]) AS TotalValue
FROM (SELECT Chain, Account, Distributor, Warehouse, StoreID, USDate, [Type of Deduction], [Total Value($)]
FROM DeductionsStoresGroupedByMonth
UNION ALL SELECT [Chain/Account/Warehouse], [Chain/Account/Warehouse2], Distributor, [Chain/Account/Warehouse3], StoreID, USDate, [Type of Deduction], [Amount($)]
FROM DeductionsByChainNoStoreID) AS [%$##@_Alias]
GROUP BY Chain, Account, Distributor, Warehouse, StoreID, USDate, [Type of Deduction];
-编辑2-
此查询(以及其他三个类似的查询)在从 Excel 链接为表格时仅显示两个空行 - 它只是一列字符串和一列整数,所以不知道这个问题是什么:
SELECT Deductions.[Distributor's Reference], Count(Deductions.StoreID) AS NumFreeCaseFills
FROM Deductions
WHERE (((Deductions.[Type of Deduction]) Like "*free case fill*") AND ((Deductions.Details) Not Like "*placement fee*"))
GROUP BY Deductions.[Distributor's Reference];