Link to home
Start Free TrialLog in
Avatar of Frank Freese
Frank FreeseFlag for United States of America

asked on

Pivot on weekday

Experts,
The query belows works but needs some help. I need this such that I can generate a report that prints M - F across the top and places the control OnTimeScrap under the appropriate day. I've tried transform and pivot but I could never gert the syntex correct, if it is even the right way to go.

SELECT tblSupervisorReporting.ProductionDate, tblLineSupervisors.SurpevisorLN, tblLineCode.LineCodeDescription, tblLineSupervisors.Shift, tblSupervisorReporting.OnTimeScrap
FROM tblShift INNER JOIN (tblLineCode INNER JOIN (tblLineSupervisors INNER JOIN tblSupervisorReporting ON tblLineSupervisors.SupervisorID = tblSupervisorReporting.SupervisorID) ON tblLineCode.LineCodeID = tblLineSupervisors.LineCodeID) ON tblShift.ShiftID = tblLineSupervisors.Shift
WHERE (((tblSupervisorReporting.ProductionDate) Between [Enter Beginning Date] And [Enter Ending Date]) AND ((tblLineSupervisors.Active)=Yes));
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

SELECT Format(tblSupervisorReporting.ProductionDate, "ddd") AS Wkday, tblLineSupervisors.SurpevisorLN, tblLineCode.LineCodeDescription, tblLineSupervisors.Shift, tblSupervisorReporting.OnTimeScrap
Avatar of Frank Freese

ASKER

How do I incorporate this into my query?
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I replaced my Select statement with yours as follows:

SELECT Format(tblSupervisorReporting.ProductionDate, "ddd") AS Wkday, tblLineSupervisors.SurpevisorLN, tblLineCode.LineCodeDescription, tblLineSupervisors.Shift, tblSupervisorReporting.OnTimeScrap
FROM tblShift INNER JOIN (tblLineCode INNER JOIN (tblLineSupervisors INNER JOIN tblSupervisorReporting ON tblLineSupervisors.SupervisorID = tblSupervisorReporting.SupervisorID) ON tblLineCode.LineCodeID = tblLineSupervisors.LineCodeID) ON tblShift.ShiftID = tblLineSupervisors.Shift
WHERE (((tblSupervisorReporting.ProductionDate) Between [Enter Beginning Date] And [Enter Ending Date]) AND ((tblLineSupervisors.Active)=Yes));

I t worked.

I then created a cross tab query using the above query:

TRANSFORM Count(qryByDateOnTimeSupervisors.OnTimeScrap) AS CountOfOnTimeScrap
SELECT qryByDateOnTimeSupervisors.SurpevisorLN, qryByDateOnTimeSupervisors.LineCodeDescription, qryByDateOnTimeSupervisors.Shift
FROM qryByDateOnTimeSupervisors
GROUP BY qryByDateOnTimeSupervisors.SurpevisorLN, qryByDateOnTimeSupervisors.LineCodeDescription, qryByDateOnTimeSupervisors.Shift
PIVOT qryByDateOnTimeSupervisors.Wkday;

I ran the query and received the following error:

The Microsoft Jet database engine does not recognize "Enter Beginning Date"  as a valid field name or expression".