query to group by month

Experts,
Here's my objective. To create a query where I sum quantity scrapped for each month by part number and line code. I got this far

SELECT tblScrapTicket.ScrapTicketDate, tblLineCode.LineCodeNumber, tblLineCode.LineCodeDescription, tblPartNumber.PartNumber, tblPartNumber.PartNumberDescription, tblScrapTicket.QuantityScrapped
FROM tblPartNumber INNER JOIN (tblScrapTicket INNER JOIN tblLineCode ON tblScrapTicket.LineCodeID = tblLineCode.LineCodeID) ON tblPartNumber.PartNumberID = tblScrapTicket.PartNumberID
WHERE (((tblScrapTicket.ScrapTicketDate) Between [Beginning Date] And [Ending Date]))
ORDER BY tblPartNumber.PartNumber;

Frank FreeseAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tomasgruenerCommented:
I would add a group by clause, which groups for the year and the month.
I'm not very used to access sql syntax, but I think you have to add following line befor the ORDER BY Clause

GROUP Format(tblScrapTicket.ScrapTicketDate, "YY.MM")
(include the year in the group clause, so you can group correctly, even if you group over several years)
0
Shanmuga SundaramDirector of Software EngineeringCommented:
check whether this helps

SELECT Format(tblScrapTicket.ScrapTicketDate, "YY.MM")tblLineCode.LineCodeNumber, tblLineCode.LineCodeDescription, tblPartNumber.PartNumber, tblPartNumber.PartNumberDescription, sum(tblScrapTicket.QuantityScrapped)
FROM tblPartNumber INNER JOIN (tblScrapTicket INNER JOIN tblLineCode ON tblScrapTicket.LineCodeID = tblLineCode.LineCodeID) ON tblPartNumber.PartNumberID = tblScrapTicket.PartNumberID
WHERE (((tblScrapTicket.ScrapTicketDate) Between [Beginning Date] And [Ending Date]))
groub by Format(tblScrapTicket.ScrapTicketDate, "YY.MM")tblLineCode.LineCodeNumber, tblLineCode.LineCodeDescription, tblPartNumber.PartNumber, tblPartNumber.PartNumberDescription
ORDER BY tblPartNumber.PartNumber;
0
Shanmuga SundaramDirector of Software EngineeringCommented:
sorry it should be as given below.

SELECT Format(tblScrapTicket.ScrapTicketDate, "YY.MM"),tblLineCode.LineCodeNumber, tblLineCode.LineCodeDescription, tblPartNumber.PartNumber, tblPartNumber.PartNumberDescription, sum(tblScrapTicket.QuantityScrapped)
FROM tblPartNumber INNER JOIN (tblScrapTicket INNER JOIN tblLineCode ON tblScrapTicket.LineCodeID = tblLineCode.LineCodeID) ON tblPartNumber.PartNumberID = tblScrapTicket.PartNumberID
WHERE (((tblScrapTicket.ScrapTicketDate) Between [Beginning Date] And [Ending Date]))
groub by Format(tblScrapTicket.ScrapTicketDate, "YY.MM"),tblLineCode.LineCodeNumber, tblLineCode.LineCodeDescription, tblPartNumber.PartNumber, tblPartNumber.PartNumberDescription
ORDER BY tblPartNumber.PartNumber;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Frank FreeseAuthor Commented:
thanks...it looks like it'll get me where i need. just had to change groub to group
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.