Created
June 28, 2018 16:20
-
-
Save chadsten/f085552354061a1da63ece5499b061d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT (SUM(ExtendedCost) / | |
(SELECT COUNT(*) AS TempCount FROM | |
(SELECT SnapDate | |
FROM EpicorReports.dbo.InventorySnapshots AS DayCount | |
WHERE Datepart(week,DayCount.SnapDate) = Datepart(week,InvSnap.SnapDate) AND Plant <> 'PROJ' | |
GROUP BY SnapDate) | |
AS NumOfDays)) | |
AS OnHandValue, | |
ItemMoveType_c, DATEPART(week, SnapDate) AS Week | |
FROM EpicorReports.dbo.InventorySnapshots AS InvSnap | |
WHERE (Plant <> 'PROJ') AND (DATEPART(year, SnapDate) > 2017) AND (DATEPART(week, SnapDate) < DATEPART(week, GETDATE())) AND (BuyToOrder = 'FALSE') | |
GROUP BY DATEPART(week, SnapDate), ItemMoveType_c | |
ORDER BY Week |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment