Solved

parameter query to sum daily quantity for each month

Posted on 2008-10-23
4
327 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
  • 3
4 Comments
 
LVL 44

Accepted Solution

by:
GRayL earned 375 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 125 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 375 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 375 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now