SELECT dbo_job.job_date,
dbo_job.job,
dbo_job.suffix,
dbo_job.item,
qry_SumCost.SumMatlPlan,
qry_SumCost.SumMatlAct,
([qty_released]*[fixovhd_rate])/[pcs_per_lbr_hr] AS lbr_cost_plan,
qry_LaborHours.fixovhd_t_lbr,
[fixovhd_t_lbr]/[qty_complete] AS [FG Actual Price]
FROM qry_SumCost
INNER JOIN (dbo_job
INNER JOIN qry_LaborHours
ON (dbo_job.job = qry_LaborHours.job)
AND (dbo_job.suffix = qry_LaborHours.suffix))
ON (qry_SumCost.job_date = dbo_job.job_date)
AND (qry_SumCost.job = dbo_job.job)
AND (qry_SumCost.suffix = dbo_job.suffix)
GROUP BY dbo_job.job_date,
dbo_job.job,
dbo_job.suffix,
dbo_job.item,
qry_SumCost.SumMatlPlan,
qry_SumCost.SumMatlAct,
([qty_released]*[fixovhd_rate])/[pcs_per_lbr_hr],
qry_LaborHours.fixovhd_t_lbr,
[fixovhd_t_lbr]/[qty_complete]
HAVING (((dbo_job.job_date) Between [Forms]![MainForm]![Text2]
And [Forms]![MainForm]![Text6])
AND ((dbo_job.job) Like "BM0*"
Or (dbo_job.job) Like "WT0*"));
当我删除表达式[fixovhd_t_lbr] / qty_complete]时,它工作正常,但是当我包含它时,它给出了错误“这个表达式输入错误,或者它太复杂而无法评估。例如,数值表达式可能包含太多复杂的元素。尝试通过将表达式的一部分分配给变量来简化表达式。“我不知道这怎么会被认为是复杂的。该表达式的两个元素都直接来自两个不同的表,并且不是表达式本身(如果有人想知道的话)。我很肯定是因为这是因为通过消除过程我偶然发现了这个问题。
答案 0 :(得分:2)
您的查询没有意义。您正在使用group by
,但没有聚合函数。这意味着having
子句中的条件可以移动到where
子句,您可以使用select distinct
代替。
所以,这可能会解决你的问题:
SELECT DISTINCT dbo_job.job_date,
dbo_job.job,
dbo_job.suffix,
dbo_job.item,
qry_SumCost.SumMatlPlan,
qry_SumCost.SumMatlAct,
([qty_released]*[fixovhd_rate])/[pcs_per_lbr_hr] AS lbr_cost_plan,
qry_LaborHours.fixovhd_t_lbr,
[fixovhd_t_lbr]/[qty_complete] AS [FG Actual Price]
FROM qry_SumCost INNER JOIN
(dbo_job INNER JOIN
qry_LaborHours
ON (dbo_job.job = qry_LaborHours.job) AND
(dbo_job.suffix = qry_LaborHours.suffix)
)
ON (qry_SumCost.job_date = dbo_job.job_date) AND
(qry_SumCost.job = dbo_job.job) AND
(qry_SumCost.suffix = dbo_job.suffix)
WHERE (((dbo_job.job_date) Between [Forms]![MainForm]![Text2] And
[Forms]![MainForm]![Text6]) And
((dbo_job.job) Like "BM0*" Or (dbo_job.job) Like "WT0*"));