Solved

parameter query to sum daily quantity for each month

Posted on 2008-10-23
4
364 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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 …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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