1
任何人都可以帮助我解决使用CrossTab查询来比较来自供应商的当前价格的问题吗? 它从工作SELECT查询中有一个子查询,对我们的价格比较,选择只在最反感的价格,这完全适用于我们需要的数据,见下图:使用子查询查询来自查询的交叉表查询
qryPriceComp:
SELECT tblPriceComp.SupplyerID, tblPriceComp.ProductID,
tblPriceComp.Effdt, tblPriceComp.CostPrice,
tblProduct.Product, tblSupplier.Supplier
FROM tblSupplier INNER JOIN
(tblProduct INNER JOIN tblPriceComp ON tblProduct.ProductID = tblPriceComp.ProductID)
ON tblSupplier.SupplierID = tblPriceComp.SupplyerID
WHERE (((tblPriceComp.Effdt) In
(SELECT MAX(B.EffDt) AS MaxOfDt FROM tblPriceComp AS B
WHERE tblPriceComp.ProductID=B.ProductID
AND tblPriceComp.SupplyerID=B.SupplyerID
AND B.EffDt <= Date()+1)));
这则用于交叉表查询 qryPriceComp_Crosstab:
TRANSFORM Sum(qryPriceComp.CostPrice) AS SumOfCostPrice
SELECT qryPriceComp.Product
FROM qryPriceComp
GROUP BY qryPriceComp.Product
ORDER BY qryPriceComp.Product, qryPriceComp.Supplier
PIVOT qryPriceComp.Supplier;
但运行时,它提供一个错误,这两个tblPriceComp.ProductID和tblSupplier.SupplierID无效。我曾尝试将它们添加为周界,但运行时会给出一个框以输入ID号,这是不好的,因为我们想要查看所有的productID和SupplyEID。如果有人能帮助它,将不胜感激!
什么是* exact *错误信息? – Andre
当交叉表查询运行时,我得到 “Microsoft Access数据库工程不能将'tblPriceComp.ProductID'识别为有效的字段名称或表达式。” 和 “Microsoft Access数据库工具不能将'tblPriceComp.SupplyerID'识别为有效的字段名称或表达式。” –
奇数。您可以尝试从qryPriceComp的SELECT列表中删除交叉表查询中未使用的所有字段,即'tblPriceComp.SupplyerID,tblPriceComp.ProductID,tblPriceComp.Effdt'。 – Andre