我无法弄清楚为什么我的查询会在标题中给出错误。确切的错误是:
您的查询不包含指定的表达式“
IIf([Standard_Shift_Rate]=0,0,Round([SumOfqty_complete]/((((Round([Uf_Shift_Standard]*[pcs_per_mch_hr],0))/[Uf_Shift_Standard])/60)*([actual_shift_length_minutes])),2))
”作为聚合函数的一部分
相关字段(OEE_Shift
)的意图是根据我在主窗体上的某些条件返回值170
(数字)。
代码:
我打算运行下面的所有代码,但我已经注释掉了我认为与此问题无关的内容。不过,如果你认为它有助于解决这个问题,你可以看看它。
SELECT /*dbo_jobtran.job,
dbo_jobtran.suffix,
dbo_job.item,
dbo_job.description,
dbo_job.Uf_Production_Line,
Sum(dbo_jobtran.qty_complete) AS SumOfqty_complete,
dbo_jobtran.shift,
IIf(Nz([Forms]![DTForm]![STCO])="",(Switch(Max([SL])="8",(Switch((Time()>=#12/30/1899 6:0:0# And Time()<#12/30/1899 14:0:0#),DateDiff("n",#12/30/1899 6:0:0#,Time()),(Time()>=#12/30/1899 14:0:0# And Time()<#12/30/1899 22:0:0#),DateDiff("n",#12/30/1899 14:0:0#,Time()),True,IIf((DateDiff("n",#10:00:00 PM#,Time())>0),DateDiff("n",#10:00:00 PM#,Time()),DateDiff("n",#10:00:00 PM#,Time()+1)))),Max([SL])="10",(Switch((Time()>=#12/30/1899 5:0:0# And Time()<#12/30/1899 15:0:0#),DateDiff("n",#12/30/1899 5:0:0#,Time()),True,DateDiff("n",#12/30/1899 15:0:0#,Time()))),Max([SL])="12",(Switch((Time()>=#12/30/1899 3:0:0# And Time()<#12/30/1899 15:0:0#),DateDiff("n",#12/30/1899 3:0:0#,Time()),True,DateDiff("n",#12/30/1899 15:0:0#,Time()))),1=1,(Switch((Time()>=#12/30/1899 6:0:0# And Time()<#12/30/1899 14:0:0#),DateDiff("n",#12/30/1899 6:0:0#,Time()),(Time()>=#12/30/1899 14:0:0# And Time()<#12/30/1899 22:0:0#),DateDiff("n",#12/30/1899 14:0:0#,Time()),True,DateDiff("n",#12/30/1899 22:0:0#,Time()))))),(DateDiff("n",[Forms]![DTForm]![STCO],Time()))) AS Mins_since_start, Sum(Round(([Uf_Pieces_Per_Labor_Hour_Bonus]/60*[charfld3]),2)) AS Rate_per_min_cons_units, dbo_jobtran.trans_date, [Uf_Standard_Crew_Size]*[Uf_Budgeted_Pieces_Per_Labor_Hr] AS Budgeted_CN_Per_Hr, dbo_item.charfld3, dbo_jrt_sch.Uf_Standard_Crew_Size, dbo_jrt_sch.Uf_Budgeted_Pieces_Per_Labor_Hr, Round(((([Uf_Standard_Crew_Size]*[Uf_Budgeted_Pieces_Per_Labor_Hr]*8*[charfld3])/7.5)/60),0) AS Budgeted_Machine_Rate_Per_Minute, Round((([Budgeted_CN_Per_Hr]*[Mins_since_start])/60),2) AS RT_EXP_BN, Round((Sum([dbo_jobtran]![qty_complete])*[charfld3])/[Mins_since_start],2) AS RT_ACT_M_Rate, Sum([dbo_jobtran]![qty_complete])-[RT_EXP_BN] AS Diff_Budget_Rate, IIf([RT_EXP_BN]=0,0,Round(((Sum([dbo_jobtran]![qty_complete])/[RT_EXP_BN])),2)) AS OEE, Round((Sum([dbo_jobtran]![qty_complete])/[Mins_since_start])*480,0) AS Projected_Num, [RT_ACT_M_Rate]-[Budgeted_Machine_Rate_Per_Minute] AS Diff_Budgeted_MacRate, dbo_job.whse, Round((Sum([dbo_jobtran]![qty_complete])/([Forms]![DTForm]![Text4]*[Mins_since_start])*60),2) AS ACT_PPLHR, Round((Sum([dbo_jobtran]![qty_complete])/([Forms]![DTForm]![Text4]*[Mins_since_start])*60),2)-[Uf_Budgeted_Pieces_Per_Labor_Hr] AS Diff_Budget_PPLHR, IIf(Nz(Forms!DTForm![STCO])="","Null field","Unknown") AS Expr1, DateDiff("n",Forms!DTForm![STCO],Time()) AS Expr2, dbo_jrt_sch.Uf_Budgeted_Crew_Size, dbo_job.Uf_Shift_Standard AS SL,
(
Switch(
Max([SL])="8",
(Switch(
(Time()>=#12/30/1899 6:0:0# And Time()<#12/30/1899 14:0:0#),
#14:00:00#,
(Time()>=#12/30/1899 14:0:0# And Time()<#12/30/1899 22:0:0#),
#22:00:00#,
True,
#06:00:00#
)),
Max([SL])="10",
(Switch(
(Time()>=#12/30/1899 5:0:0# And Time()<#12/30/1899 15:0:0#),
#15:00:00#,
True,
#01:00:00#
)),
Max([SL])="12",
(Switch(
(Time()>=#12/30/1899 3:0:0# And Time()<#12/30/1899 15:0:0#),
#15:00:00#,
True,
#03:00:00#
))
)
) AS end_time,
Nz([Forms]![DTForm]![STCO],
(Switch(
Max([SL])="8",
(Switch(
(Time()>=#12/30/1899 6:0:0# And Time()<#12/30/1899 14:0:0#),
DateDiff("n",#12/30/1899 6:0:0#,Time()),
(Time()>=#12/30/1899 14:0:0# And Time()<#12/30/1899 22:0:0#),
DateDiff("n",#12/30/1899 14:0:0#,Time()),
True,
IIf((DateDiff("n",#10:00:00 PM#,Time())>0),
DateDiff("n",#10:00:00 PM#,Time()),
DateDiff("n",#10:00:00 PM#,Time()+1)))),
Max([SL])="10",
(Switch(
(Time()>=#12/30/1899 5:0:0# And Time()<#12/30/1899 15:0:0#),
DateDiff("n",#12/30/1899 5:0:0#,Time()),
True,
DateDiff("n",#12/30/1899 15:0:0#,Time()))),
Max([SL])="12",
(Switch(
(Time()>=#12/30/1899 3:0:0# And Time()<#12/30/1899 15:0:0#),
DateDiff("n",#12/30/1899 3:0:0#,Time()),
True,
DateDiff("n",#12/30/1899 15:0:0#,Time()))),
1=1,
(Switch(
(Time()>=#12/30/1899 6:0:0# And Time()<#12/30/1899 14:0:0#),
DateDiff("n",#12/30/1899 6:0:0#,Time()),
(Time()>=#12/30/1899 14:0:0# And Time()<#12/30/1899 22:0:0#),
DateDiff("n",#12/30/1899 14:0:0#,Time()),
True,
DateDiff("n",#12/30/1899 22:0:0#,Time())))
))
) AS start_time,
(DateDiff("n", [start_time], [end_time])) AS actual_shift_length_minutes,*/
IIf([Standard_Shift_Rate]=0,0,Round([SumOfqty_complete]/((((Round([Uf_Shift_Standard]*[pcs_per_mch_hr],0))/[Uf_Shift_Standard])/60)*([actual_shift_length_minutes])),2)) AS OEE_Shift
FROM dbo_jrt_sch
INNER JOIN ((dbo_job
INNER JOIN dbo_jobtran ON (dbo_job.job = dbo_jobtran.job)
AND (dbo_job.suffix = dbo_jobtran.suffix))
INNER JOIN dbo_item ON dbo_job.item = dbo_item.item) ON (dbo_jrt_sch.job = dbo_job.job)
AND (dbo_jrt_sch.suffix = dbo_job.suffix)
GROUP BY dbo_jobtran.job,
dbo_jobtran.suffix,
dbo_job.item,
dbo_job.description,
dbo_job.Uf_Production_Line,
dbo_jobtran.shift,
dbo_jobtran.trans_date,
[Uf_Standard_Crew_Size]*[Uf_Budgeted_Pieces_Per_Labor_Hr],
dbo_item.charfld3,
dbo_jrt_sch.Uf_Standard_Crew_Size,
dbo_jrt_sch.Uf_Budgeted_Pieces_Per_Labor_Hr,
Round(((([Uf_Standard_Crew_Size]*[Uf_Budgeted_Pieces_Per_Labor_Hr]*8*[charfld3])/7.5)/60),0),
dbo_job.whse,
IIf(Nz(Forms!DTForm![STCO])="","Null field","Unknown"),
DateDiff("n",Forms!DTForm![STCO],Time()),
dbo_jrt_sch.Uf_Budgeted_Crew_Size,
dbo_job.Uf_Shift_Standard,
OEE_Shift
HAVING (((dbo_jobtran.job)=[Forms]![DTForm]![Text116])
AND ((dbo_jobtran.suffix)=[Forms]![DTForm]![Text118])
AND ((dbo_jobtran.shift)=[Forms]![DTForm]![Combo33])
AND ((dbo_jobtran.trans_date)=[Forms]![DTForm]![Text29])
AND ((dbo_jrt_sch.Uf_Budgeted_Pieces_Per_Labor_Hr) IS NOT NULL));