Created
September 5, 2017 19:06
-
-
Save chadsten/591d8984b50fe1f1af487e9d7de3fa8b 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 | |
PartNum, | |
CONVERT(DECIMAL(16, 4), (SUM(OurShipQty) * .5)) AS QuarterTotal, | |
CONVERT(DECIMAL(16, 4), (SUM(OurShipQty) / 3) * .5) AS MonthAvg, | |
CONVERT(DECIMAL(16, 4), (((STDEV(OurShipQty)) * .5) * (COUNT(PartNum) * .5))) AS MonthStd, | |
CONVERT(DECIMAL(16, 4), (AVG(OurShipQty)) * .5) AS PartAvg, | |
CONVERT(DECIMAL(16, 4), (STDEV(OurShipQty)) * .5) AS PartStd, | |
CONVERT(DECIMAL(16, 4), (COUNT(PartNum)) * .5) AS Hits, | |
COUNT(DISTINCT CustID) AS Customers, | |
Plant | |
FROM | |
dbo.v_InvoiceRegister | |
WHERE | |
(InvoiceDate > DATEADD(month, - 12, GETDATE())) AND | |
(InvoiceDate <= DATEADD(month, - 9, GETDATE())) AND | |
(TermsCode NOT IN ('16', '26', '14', 'PORD', '50%D', '50%S')) AND | |
(NetExtPrice > 0) AND | |
(BuyToOrder <> 'TRUE') | |
GROUP BY | |
PartNum, | |
Plant |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment