C
Cindy
I'm trying to get the average minutes for each unique lane per customer. I'm
using a totals query (obviously not correctly) but having issues.
I want to subtract the Arrival time from the Departure time, then subtract
720 minutes from any that are over 720 minutes (to account for overnight,
non-driving time) and THEN average what is left. I have broken it down into
three calculations because it didn't like it any other way but I am stuck on
the last one. The AvgEditedTime gives me the error that it can't do a
subquery on the aggregate of the Edited Time IIf statement. For the RunTime
I am putting Sum in the Totals row and in EditedTime I have Expression, I
have tried Expression, Where, Sum and Avg in the AvgEditedTime with no luck.
I'm not sure I'm even on the right track here but I'm putting my SQL here in
hopes someone can point me in the right direction.
SELECT [Prof Rev3].[T0Customer_Id], [Prof Rev3].[T3City_Name], [Prof
Rev3].[T4City_Name], Sum(DateDiff("n",[Departure],[Arrival])) AS RunTime,
IIf([RunTime]>720,[RunTime]-720,[RunTime]) AS EditedTime, Avg([EditedTime])
AS AvgEditedTime, [Prof Rev3].[T2Loaded]
FROM [Prof Rev3]
GROUP BY [Prof Rev3].[T0Customer_Id], [Prof Rev3].[T3City_Name], [Prof
Rev3].[T4City_Name], [Prof Rev3].[T2Loaded]
HAVING ((([Prof Rev3].[T2Loaded])="L"))
ORDER BY [Prof Rev3].[T0Customer_Id], [Prof Rev3].[T3City_Name], [Prof
Rev3].[T4City_Name];
Thanks in advance!!!
Cindy
using a totals query (obviously not correctly) but having issues.
I want to subtract the Arrival time from the Departure time, then subtract
720 minutes from any that are over 720 minutes (to account for overnight,
non-driving time) and THEN average what is left. I have broken it down into
three calculations because it didn't like it any other way but I am stuck on
the last one. The AvgEditedTime gives me the error that it can't do a
subquery on the aggregate of the Edited Time IIf statement. For the RunTime
I am putting Sum in the Totals row and in EditedTime I have Expression, I
have tried Expression, Where, Sum and Avg in the AvgEditedTime with no luck.
I'm not sure I'm even on the right track here but I'm putting my SQL here in
hopes someone can point me in the right direction.
SELECT [Prof Rev3].[T0Customer_Id], [Prof Rev3].[T3City_Name], [Prof
Rev3].[T4City_Name], Sum(DateDiff("n",[Departure],[Arrival])) AS RunTime,
IIf([RunTime]>720,[RunTime]-720,[RunTime]) AS EditedTime, Avg([EditedTime])
AS AvgEditedTime, [Prof Rev3].[T2Loaded]
FROM [Prof Rev3]
GROUP BY [Prof Rev3].[T0Customer_Id], [Prof Rev3].[T3City_Name], [Prof
Rev3].[T4City_Name], [Prof Rev3].[T2Loaded]
HAVING ((([Prof Rev3].[T2Loaded])="L"))
ORDER BY [Prof Rev3].[T0Customer_Id], [Prof Rev3].[T3City_Name], [Prof
Rev3].[T4City_Name];
Thanks in advance!!!
Cindy