B
BruceM
This is the SQL for a select (Totals) query that shows me the number of
parts per category that have been processed according to a particular
Technical Plan:
ProcName PartCat QtySum PartNum
----------- -------- -------- --------
Plate Gear 100 12345
Plate Gear 50 54321
This listing shows two jobs of 50 parts each (PartNum 12345) and one job of
50 parts of 54321. The two jobs for PartNum 12345 were consolidated into
one row. What I want is for all three jobs to be consolidated into one row
for Plating jobs on Gears:
ProcName PartCat QtySum
----------- -------- --------
Plate Gear 150
PartNum is in the first example for clarity. In practice I don't need the
PartNum to show, but whether it shows or not, the quantities are separated
as shown in the first example. How do I tell the query to sum the PartQty
for all of the Plate jobs on Gears? Here is the SQL:
SELECT tblProcess.ProcName, tblPart.PartCat,
DSum("[PartQty]","[tblJob]","[PartID_Job] = " & [PartID] & " AND
[PlanID_Job] = " & [PlanID])
AS QtySum, tblPart.PartNum
FROM tblPart
INNER JOIN ((tblTechPlan
INNER JOIN tblJob
ON tblTechPlan.PlanID = tblJob.PlanID_Job)
INNER JOIN (tblProcess
INNER JOIN tjctPlanProc
ON tblProcess.ProcessID = tjctPlanProc.ProcessID_PlanProc)
ON tblTechPlan.PlanID = tjctPlanProc.PlanID_PlanProc)
ON tblPart.PartID = tblJob.PartID_Job
GROUP BY tblProcess.ProcName, tblPart.PartCat,
DSum("[PartQty]","[tblJob]","[PartID_Job] = " & [PartID] & " AND
[PlanID_Job] = " & [PlanID]), tblPart.PartNum
ORDER BY tblProcess.ProcName, tblPart.PartCat;
I also tried making a query (qryCategory) from tblPart:
SELECT tblPart.PartID, tblPart.PartCat
FROM tblPart;
and substituting qryCategory.PartID and qryCategory.PartCat for
tblPart.PartID and tblPart.PartCat as needed, but still the same result
because the joining field (PartID) is different when the part numbers are
different.
parts per category that have been processed according to a particular
Technical Plan:
ProcName PartCat QtySum PartNum
----------- -------- -------- --------
Plate Gear 100 12345
Plate Gear 50 54321
This listing shows two jobs of 50 parts each (PartNum 12345) and one job of
50 parts of 54321. The two jobs for PartNum 12345 were consolidated into
one row. What I want is for all three jobs to be consolidated into one row
for Plating jobs on Gears:
ProcName PartCat QtySum
----------- -------- --------
Plate Gear 150
PartNum is in the first example for clarity. In practice I don't need the
PartNum to show, but whether it shows or not, the quantities are separated
as shown in the first example. How do I tell the query to sum the PartQty
for all of the Plate jobs on Gears? Here is the SQL:
SELECT tblProcess.ProcName, tblPart.PartCat,
DSum("[PartQty]","[tblJob]","[PartID_Job] = " & [PartID] & " AND
[PlanID_Job] = " & [PlanID])
AS QtySum, tblPart.PartNum
FROM tblPart
INNER JOIN ((tblTechPlan
INNER JOIN tblJob
ON tblTechPlan.PlanID = tblJob.PlanID_Job)
INNER JOIN (tblProcess
INNER JOIN tjctPlanProc
ON tblProcess.ProcessID = tjctPlanProc.ProcessID_PlanProc)
ON tblTechPlan.PlanID = tjctPlanProc.PlanID_PlanProc)
ON tblPart.PartID = tblJob.PartID_Job
GROUP BY tblProcess.ProcName, tblPart.PartCat,
DSum("[PartQty]","[tblJob]","[PartID_Job] = " & [PartID] & " AND
[PlanID_Job] = " & [PlanID]), tblPart.PartNum
ORDER BY tblProcess.ProcName, tblPart.PartCat;
I also tried making a query (qryCategory) from tblPart:
SELECT tblPart.PartID, tblPart.PartCat
FROM tblPart;
and substituting qryCategory.PartID and qryCategory.PartCat for
tblPart.PartID and tblPart.PartCat as needed, but still the same result
because the joining field (PartID) is different when the part numbers are
different.