• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

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));
0
Frank Freese
Asked:
Frank Freese
  • 2
  • 2
1 Solution
 
Patrick MatthewsCommented:
SELECT Format(tblSupervisorReporting.ProductionDate, "ddd") AS Wkday, tblLineSupervisors.SurpevisorLN, tblLineCode.LineCodeDescription, tblLineSupervisors.Shift, tblSupervisorReporting.OnTimeScrap
0
 
Frank FreeseAuthor Commented:
How do I incorporate this into my query?
0
 
Patrick MatthewsCommented:
Use that new SELECT clause instead of the old one, and then use the Crosstab Wizard to build a corsstab
based on that query you just made.
0
 
Frank FreeseAuthor Commented:
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".
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now