Pardon this easy question :)

asusetyo

Board Regular
Joined
Feb 18, 2014
Messages
50
Hi All,

Good Morning from Indonesia,
Sorry, please bear with the code :)
So basically this Code works, and I want to put another complicated (*for me) field
I have Stock_On_Hand form table ZinQ Template, but I have difficulty to generate National_Stock_On_Hand
Logic of National_Stock_On_Hand is just by sum-ing Stock_On_Hand based on Week & Product Code in table ZinQ Template, (*sum-ing all Plant)

Code:
SELECT Left([Week],7) AS APL_Month, 
[ZinQ Template].Week AS APL_Week, 
[Principal Master].[Division Code], 
[Principal Master].[Division Name], 
[Principal Master].[Principal Name], 
[ZinQ Template].[Product Code], 
[ZinQ Template].[Product Description], 
[ZinQ Template].Plant, 
[Branch Master].[Fac# Description], 
Sum([Forecast Template].[Forecast Qty]) AS Forecast_Qty, 
Sum([Forecast Template].[Forecast Value]) AS Forecast_Value, 
Sum([ZinQ Template].[Stock On Hand]) AS Stock_On_Hand, 
Sum([ZinQ Template].Intransit) AS Intransit_Stock, 
Sum([ZinQ Template].[AMS 3]) AS AMS_3, 
Sum([ZinQ Template].[Safe Stock]) AS Safety_Stock, 
Sum([Order Template].[PO Qty]) AS PO_Qty, 
Sum([Order Template].[Invoice Qty]) AS Invoice_Qty, 
Sum([Order Template].[Loss Qty]) AS Loss_Qty, 
Sum([Order Template].[PO Value]) AS PO_Value, 
Sum([Order Template].[Invoice Value]) AS Invoice_Value, 
Sum([Order Template].[Loss Value]) AS Loss_Value, 
Sum([Order Template].[Loss Qty - Partial Complete]) AS [Loss_Qty - Partial Complete], 
Sum([Order Template].[Loss Qty - Reject StockOut]) AS [Loss_Qty - Reject StockOut], 
Sum([Order Template].[Loss Qty - Reject by Finance]) AS [Loss_Qty - Reject by Finance], 
Sum([Order Template].[Loss Qty - Reject Others]) AS [Loss_Qty - Reject Others], 
Sum([Order Template].[Loss Qty - Work in progress Finance]) AS [Loss_Qty - Work in progress Finance], 
Sum([Order Template].[Loss Qty - Work in Progress Logistic]) AS [Loss_Qty - Work in Progress Logistic]

FROM [Principal Master] 
INNER JOIN ([Product Master] 
INNER JOIN (([Order Template] 
RIGHT JOIN ([Forecast Template] 
RIGHT JOIN [ZinQ Template] 
ON [Forecast Template].Lookup = [ZinQ Template].Lookup) 
ON [Order Template].Lookup = [ZinQ Template].Lookup) 
INNER JOIN [Branch Master] 
ON [ZinQ Template].Plant = [Branch Master].[Facility Code]) 
ON [Product Master].MATERIAL = [ZinQ Template].[Product Code]) 
ON [Principal Master].[Division Code] = [Product Master].DV

GROUP BY Left([Week],7), [ZinQ Template].Week, [Principal Master].[Division Code], 
[Principal Master].[Division Name], [Principal Master].[Principal Name], 
[ZinQ Template].[Product Code], [ZinQ Template].[Product Description], 
[ZinQ Template].Plant, [Branch Master].[Fac# Description]

ORDER BY [ZinQ Template].Week, [Principal Master].[Division Code], 
[ZinQ Template].[Product Code], [ZinQ Template].Plant;

Thanks before,
Aditeyo
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,221,848
Messages
6,162,415
Members
451,762
Latest member
Brainsanquine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top