【发布时间】:2018-07-24 21:05:52
【问题描述】:
创建一个查询,根据成品预测分析整个工厂需要生产什么。每月需求被拉入,但试图弄清楚如何轻松选择要查看的月份,因为它们是单独的列。
下面的 SQL 是我目前拥有的,我想从用户输入中对变量进行 DIM 处理,以选择加粗的数字(月份)。前任。用户输入“4”,它变为[MPS 客户预测]![4]。提前感谢您的帮助。
SELECT [MPS Customer Forecast]![Part] AS [Finished Good]
, [MPSCustomer Forecast].Part
, ***[MPS Customer Forecast]![3]*** AS [MonthDemand]
, BOMs.[Component No]
, BOMs.[Component Name]
, BOMs.[BOMQuantity]
, ([BOMs]![BOM Quantity][MPS Customer Forecast]![3]***) AS [Comp Month Dem]
, [Active Routings - Primary].[Approved WorkcenterRates]
,[MPS Customer Forecast]![3][BOMs]![BOM Quantity]/[Active
Routings - Primary]![Approved Workcenter Rates] AS [Needed Hours]
,[Active Routings - Primary].[Workcenter Code]
【问题讨论】:
-
Dimis VBA,但我没有看到任何 VBA。另外,我没有看到完整的 SQL 语句。那么这个查询在哪里呢?在 VBA 程序中?它是否意味着在数据库中保存查询?似乎[MPS Customer Forecast]类似于交叉表查询,所以我建议不要这样做。改为使用交叉表查询中的计算并按月过滤。 -
嗨 WolfgangK。是的,它在数据库中保存的查询中。这是一个简化的 Access SQL 以突出显示我正在查看的内容。有“..Forecast]![3]”的地方是我希望能够输入变量的地方。由于每个月的需求是他们自己的领域,所以我不能那样选择标准...................................... .. SELECT [MPS Customer Forecast].Part, [MPS Customer Forecast]![2] AS [Month Demand] FROM [MPS Customer Forecast];
标签: sql-server ms-access