M
mistux
I have the following stored procedure that shows me the total pounds o
material that I need per record. Now I want to be able to also kno
what the Grand Total of punds is.
I have indicated the line that give me the individual total.
I am actually going to be displaying this at the bottom of a subform i
Access (in Access when I was using an MDB to hold the data, the subfor
worked, but when I moved it to SQL it stops working)
Do I need to create a new sp to sum this sp or what?
Code
-------------------
SELECT vOpenOrderWeightFeetProjection.Customer,
vOpenOrderWeightFeetProjection.[Shop Order],
vOpenOrderWeightFeetProjection.[Due Date],
vOpenOrderWeightFeetProjection.Revision,
vOpenOrderWeightFeetProjection.ComboCustPartNum,
==> Sum(vOpenOrderWeightFeetProjection.[Total Pounds]) AS [SumOfTotal_Pounds], <==**
Sum(vOpenOrderWeightFeetProjection.[Total Feet]) AS [SumOfTotal_Feet],
[T_SetupSheetHistoryMaterialDetail].RawMatComponentID,
[T_MaterialComponents].MatDesc,
[T_SetupSheetHistoryCombinationsDetail].LetDown,
([T_SetupSheetHistoryCombinationsDetail].[Letdown]/100)*Sum(vOpenOrderWeightFeetProjection.[Total Pounds]) AS ColorantLbs,
[T_SetupSheetHistoryCombinationsDetail].ComponentID,
[T_MaterialComponents_2].MatDesc as MatDesc2,
[T_SetupSheetHistoryMaterialDetail].AddLetDown,
([AddLetDown]/100)*Sum(vOpenOrderWeightFeetProjection.[Total Pounds]) AS AddtvLbs,
[T_SetupSheetHistoryMaterialDetail].AddMatComponentID,
[T_MaterialComponents_1].MatDesc as MatDesc1,
[T_SetupSheetHistoryMaterialDetail].PiecesPerCartn,
/* IIf([PiecesPerCartn]=0,0,[SumOfTotal Feet]/[PiecesPerCartn]) AS PkgFt, */
(
CASE
WHEN [PiecesPerCartn] =0
THEN 0
ELSE Sum(vOpenOrderWeightFeetProjection.[Total Feet])/[PiecesPerCartn]
END
) AS PkgFt,
[T_SetupSheetHistoryMaterialDetail].PackageID,
[T_MaterialComponents_4].MatDesc as MatDesc4
FROM (vOpenOrderWeightFeetProjection
INNER JOIN ((((([T_SetupSheetHistoryMaterialDetail]
INNER JOIN [T_SetupSheetHistoryCombinationsDetail]
ON ([T_SetupSheetHistoryMaterialDetail].WOIDSub = [T_SetupSheetHistoryCombinationsDetail].WOIDSub)
AND ([T_SetupSheetHistoryMaterialDetail].WOID = [T_SetupSheetHistoryCombinationsDetail].WOID))
LEFT JOIN [T_MaterialComponents]
ON [T_SetupSheetHistoryMaterialDetail].RawMatComponentID = [T_MaterialComponents].ComponentID)
LEFT JOIN [T_MaterialComponents] AS [T_MaterialComponents_1]
ON [T_SetupSheetHistoryMaterialDetail].AddMatComponentID = [T_MaterialComponents_1].ComponentID)
LEFT JOIN [T_MaterialComponents] AS [T_MaterialComponents_4]
ON [T_SetupSheetHistoryMaterialDetail].PackageID = [T_MaterialComponents_4].ComponentID)
LEFT JOIN [T_MaterialComponents] AS [T_MaterialComponents_2]
ON [T_SetupSheetHistoryCombinationsDetail].ComponentID = [T_MaterialComponents_2].ComponentID)
ON (vOpenOrderWeightFeetProjection.WOIDSub = [T_SetupSheetHistoryMaterialDetail].WOIDSub)
AND (vOpenOrderWeightFeetProjection.Revision = [T_SetupSheetHistoryMaterialDetail].Revision)
AND (vOpenOrderWeightFeetProjection.ComboCustPartNum = [T_SetupSheetHistoryCombinationsDetail].ComboCustPartNum)
AND (vOpenOrderWeightFeetProjection.[Shop Order] = [T_SetupSheetHistoryMaterialDetail].WOID))
LEFT JOIN [T_SetupSheetKitMaster]
ON [T_SetupSheetHistoryCombinationsDetail].ComboCustPartNum = [T_SetupSheetKitMaster].KitItemPartNum
WHERE ((([T_SetupSheetKitMaster].KitItemPartNum) Is Null))
GROUP BY vOpenOrderWeightFeetProjection.Customer,
vOpenOrderWeightFeetProjection.[Shop Order],
vOpenOrderWeightFeetProjection.[Due Date],
vOpenOrderWeightFeetProjection.Revision,
vOpenOrderWeightFeetProjection.ComboCustPartNum,
[T_SetupSheetHistoryMaterialDetail].RawMatComponentID,
[T_MaterialComponents].MatDesc,
[T_SetupSheetHistoryCombinationsDetail].LetDown,
[T_SetupSheetHistoryCombinationsDetail].ComponentID,
[T_MaterialComponents_2].MatDesc,
[T_SetupSheetHistoryMaterialDetail].AddLetDown,
[T_SetupSheetHistoryMaterialDetail].AddMatComponentID,
[T_MaterialComponents_1].MatDesc,
[T_SetupSheetHistoryMaterialDetail].PiecesPerCartn,
[T_SetupSheetHistoryMaterialDetail].PackageID,
[T_MaterialComponents_4].MatDesc
HAVING ((([T_SetupSheetHistoryMaterialDetail].RawMatComponentID)=1044))
OR ((([T_SetupSheetHistoryCombinationsDetail].ComponentID)=1044))
OR ((([T_SetupSheetHistoryMaterialDetail].AddMatComponentID)=1044))
OR((([T_SetupSheetHistoryMaterialDetail].PackageID)=1044))
--------------------
material that I need per record. Now I want to be able to also kno
what the Grand Total of punds is.
I have indicated the line that give me the individual total.
I am actually going to be displaying this at the bottom of a subform i
Access (in Access when I was using an MDB to hold the data, the subfor
worked, but when I moved it to SQL it stops working)
Do I need to create a new sp to sum this sp or what?
Code
-------------------
SELECT vOpenOrderWeightFeetProjection.Customer,
vOpenOrderWeightFeetProjection.[Shop Order],
vOpenOrderWeightFeetProjection.[Due Date],
vOpenOrderWeightFeetProjection.Revision,
vOpenOrderWeightFeetProjection.ComboCustPartNum,
==> Sum(vOpenOrderWeightFeetProjection.[Total Pounds]) AS [SumOfTotal_Pounds], <==**
Sum(vOpenOrderWeightFeetProjection.[Total Feet]) AS [SumOfTotal_Feet],
[T_SetupSheetHistoryMaterialDetail].RawMatComponentID,
[T_MaterialComponents].MatDesc,
[T_SetupSheetHistoryCombinationsDetail].LetDown,
([T_SetupSheetHistoryCombinationsDetail].[Letdown]/100)*Sum(vOpenOrderWeightFeetProjection.[Total Pounds]) AS ColorantLbs,
[T_SetupSheetHistoryCombinationsDetail].ComponentID,
[T_MaterialComponents_2].MatDesc as MatDesc2,
[T_SetupSheetHistoryMaterialDetail].AddLetDown,
([AddLetDown]/100)*Sum(vOpenOrderWeightFeetProjection.[Total Pounds]) AS AddtvLbs,
[T_SetupSheetHistoryMaterialDetail].AddMatComponentID,
[T_MaterialComponents_1].MatDesc as MatDesc1,
[T_SetupSheetHistoryMaterialDetail].PiecesPerCartn,
/* IIf([PiecesPerCartn]=0,0,[SumOfTotal Feet]/[PiecesPerCartn]) AS PkgFt, */
(
CASE
WHEN [PiecesPerCartn] =0
THEN 0
ELSE Sum(vOpenOrderWeightFeetProjection.[Total Feet])/[PiecesPerCartn]
END
) AS PkgFt,
[T_SetupSheetHistoryMaterialDetail].PackageID,
[T_MaterialComponents_4].MatDesc as MatDesc4
FROM (vOpenOrderWeightFeetProjection
INNER JOIN ((((([T_SetupSheetHistoryMaterialDetail]
INNER JOIN [T_SetupSheetHistoryCombinationsDetail]
ON ([T_SetupSheetHistoryMaterialDetail].WOIDSub = [T_SetupSheetHistoryCombinationsDetail].WOIDSub)
AND ([T_SetupSheetHistoryMaterialDetail].WOID = [T_SetupSheetHistoryCombinationsDetail].WOID))
LEFT JOIN [T_MaterialComponents]
ON [T_SetupSheetHistoryMaterialDetail].RawMatComponentID = [T_MaterialComponents].ComponentID)
LEFT JOIN [T_MaterialComponents] AS [T_MaterialComponents_1]
ON [T_SetupSheetHistoryMaterialDetail].AddMatComponentID = [T_MaterialComponents_1].ComponentID)
LEFT JOIN [T_MaterialComponents] AS [T_MaterialComponents_4]
ON [T_SetupSheetHistoryMaterialDetail].PackageID = [T_MaterialComponents_4].ComponentID)
LEFT JOIN [T_MaterialComponents] AS [T_MaterialComponents_2]
ON [T_SetupSheetHistoryCombinationsDetail].ComponentID = [T_MaterialComponents_2].ComponentID)
ON (vOpenOrderWeightFeetProjection.WOIDSub = [T_SetupSheetHistoryMaterialDetail].WOIDSub)
AND (vOpenOrderWeightFeetProjection.Revision = [T_SetupSheetHistoryMaterialDetail].Revision)
AND (vOpenOrderWeightFeetProjection.ComboCustPartNum = [T_SetupSheetHistoryCombinationsDetail].ComboCustPartNum)
AND (vOpenOrderWeightFeetProjection.[Shop Order] = [T_SetupSheetHistoryMaterialDetail].WOID))
LEFT JOIN [T_SetupSheetKitMaster]
ON [T_SetupSheetHistoryCombinationsDetail].ComboCustPartNum = [T_SetupSheetKitMaster].KitItemPartNum
WHERE ((([T_SetupSheetKitMaster].KitItemPartNum) Is Null))
GROUP BY vOpenOrderWeightFeetProjection.Customer,
vOpenOrderWeightFeetProjection.[Shop Order],
vOpenOrderWeightFeetProjection.[Due Date],
vOpenOrderWeightFeetProjection.Revision,
vOpenOrderWeightFeetProjection.ComboCustPartNum,
[T_SetupSheetHistoryMaterialDetail].RawMatComponentID,
[T_MaterialComponents].MatDesc,
[T_SetupSheetHistoryCombinationsDetail].LetDown,
[T_SetupSheetHistoryCombinationsDetail].ComponentID,
[T_MaterialComponents_2].MatDesc,
[T_SetupSheetHistoryMaterialDetail].AddLetDown,
[T_SetupSheetHistoryMaterialDetail].AddMatComponentID,
[T_MaterialComponents_1].MatDesc,
[T_SetupSheetHistoryMaterialDetail].PiecesPerCartn,
[T_SetupSheetHistoryMaterialDetail].PackageID,
[T_MaterialComponents_4].MatDesc
HAVING ((([T_SetupSheetHistoryMaterialDetail].RawMatComponentID)=1044))
OR ((([T_SetupSheetHistoryCombinationsDetail].ComponentID)=1044))
OR ((([T_SetupSheetHistoryMaterialDetail].AddMatComponentID)=1044))
OR((([T_SetupSheetHistoryMaterialDetail].PackageID)=1044))
--------------------