使用Excel 2007,我使用Data> From Access按钮链接到Access查询,并将其设置为显示为表格。所有行都存在,除了任何类型为“安置费”。
E.g。在下面的示例中,免费案例填写扣除显示在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
-edit -
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];
-edit 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];
答案 0 :(得分:1)
对Like
模式尝试ANSI-92 Query mode wild card characters。
WHERE
Deductions.[Type of Deduction] Like "%free case fill%"
AND Deductions.Details Not Like "%placement fee%"