Simple Query

ggodwin

Registered User.
Local time
Today, 03:27
Joined
Oct 20, 2008
Messages
112
I have a query that I want to summarize based on the results in the table.

Example:

I have 10 records and 2 fields.

One field is called QPR and another field is called Qty (interger)

Three of the 10 records have ABC in the QPR number, 2 of them DEF in the QPR field and 5 have XYZ. I would like to summarize the Qty field based on these records.

Table1
QPR - Qty
ABC - 2
XYZ -1
DEF - 6
ABC -7
XYZ - 2
DEF - 10
ABC - 3
XYZ - 8
XYZ - 2
XYZ - 5

Query results:
ABC - 12
DEF - 16
XYZ - 18

Thanks!!
 
Try something like

Code:
SELECT table1.QPR, Sum(Table1.Qty) AS TotalQty
FROM table1 GROUP BY table1.QPR;
 
Yep that appears to be what I needed.
 
Now I have applied it to my application and I may have done it wrong.
Here is what I am trying to do.

From Table SkpiProblemLOg
SUM/Group by by QPRQPINumber

But I want to use several more fields (Date,PartNumber,PartName,DefectDesription,QPRQPINumber,Qty

Filtered by ModelCode ="VENZA"

Code:
SELECT SkpiProblemLog.Date, SkpiProblemLog.PartNumber, SkpiProblemLog.PartName, SkpiProblemLog.DefectDescription, SkpiProblemLog.QPRQPINumber, Sum(SkpiProblemLog.Quantity) AS TotalQty, SkpiProblemLog.ModelCode
FROM SkpiProblemLog
GROUP BY SkpiProblemLog.QPRQPINumber
HAVING (((SkpiProblemLog.ModelCode)="VENZA"));
 
Try:

SELECT S.Date, S.PartNumber, S.PartName, S.DefectDescription, S.QPRQPINumber, Sum(S.Quantity) AS TotalQty, S.ModelCode
FROM SkpiProblemLog S
GROUP BY S.Date, S.PartNumber, S.PartName, S.DefectDescription, S.QPRQPINumber, S.ModelCode
HAVING S.ModelCode='VENZA';
 

Users who are viewing this thread

Back
Top Bottom