?
Solved

parameter query to sum daily quantity for each month

Posted on 2008-10-23
4
Medium Priority
?
371 Views
Last Modified: 2012-05-05
Experts,
I have two tables - tblPartNumber, tblQuanityScrapped
tblQuantityScrapped fields used:
ScrapDate
PartNumberID
QuanityScrapped

tblPartNumber
PartNumberID
PartNumber
PartNumberDescription

My query is a date parameter query on ScrapDate. What has been requested is a query that totals the quantity of each part for the month. For example Part 123 could have 25 for Month 1, Part 124 could have 35 for Month 1 with the process being repeated for each month in the query.
0
Comment
Question by:Frank Freese
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 44

Accepted Solution

by:
GRayL earned 1500 total points
ID: 22789456
This do it?

SELECT a.PartNumber, a.Description, Month(b.ScrapDate) as MonthNum Sum(b.QuantityScrapped) as MonthlyTotal FROM tblPartNumber a INNER JOIN tblQuantityScrapped b ON a.PartNumberID = b.PartNumberID GROUP BY a.PartNumber, a.Description, Month(b.ScrapDate);
0
 
LVL 16

Assisted Solution

by:Sheils
Sheils earned 500 total points
ID: 22789482
Try this

SELECT PartNumberID, Sum(QuanityScrapped) AS SumScraped
FROM tblPartNumber INNER JOIN  tblQuanityScrapped
ON tblPartNumber.PartNumberID= tblQuanityScrapped.PartNumberID
HAVING ScrapDate between [Start Date] AND [End Date]
0
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 1500 total points
ID: 22789487
Come to think of it, if the table has multi-year values consider this:

SELECT a.PartNumber, a.Description, Format(b.ScrapDate,"yymm") as YrMonNum Sum(b.QuantityScrapped) as MonthlyTotal FROM tblPartNumber a INNER JOIN tblQuantityScrapped b ON a.PartNumberID = b.PartNumberID GROUP BY a.PartNumber, a.Description, Format(b.ScrapDate,"yymm");
0
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 1500 total points
ID: 22789510
If you wanted to limit it to a given year:

SELECT a.PartNumber, a.Description, Format(b.ScrapDate,"yymm") as YrMonNum Sum(b.QuantityScrapped) as MonthlyTotal FROM tblPartNumber a INNER JOIN tblQuantityScrapped b ON a.PartNumberID = b.PartNumberID
WHERE Year(b.ScrapDate) = [Enter Year nnnn]
GROUP BY a.PartNumber, a.Description, Format(b.ScrapDate,"yymm");

When prompted you would enter a 4 digit year.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question