Created
February 7, 2017 17:43
-
-
Save chadsten/d67892d593fb00a80592df15d0199269 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 TOP (100) PERCENT MAX(LastRecDate) AS LastRecDate, PartNum, Plant, MAX(LastPONum) AS LastPONum | |
FROM (SELECT MAX(TranDate) AS LastRecDate, PartNum, Plant, CAST(MAX(PONum) AS varchar(30)) AS LastPONum | |
FROM Epicor10.Erp.PartTran | |
WHERE (TranType IN ('PUR-STK', 'ADJ-QTY')) AND (TranDate <> '2016-09-30') | |
GROUP BY PartNum, Plant | |
UNION | |
SELECT LAST_REC_DATE, PROD_NUM, CASE WHEN WHSE_NUM IN ('10', '17', '19') THEN 'DIST' WHEN WHSE_NUM IN ('18', '90') | |
THEN 'PROJ' WHEN WHSE_NUM = '15' THEN 'FREE' ELSE WHSE_NUM END AS Plant, PO_LAST_RECPT AS PONum | |
FROM dbo.WHSE_STAT | |
WHERE (LAST_REC_DATE IS NOT NULL) AND (NOT (WHSE_NUM IN ('11', '20', '30')))) AS LRD | |
WHERE (LastRecDate > '2008-01-01') | |
GROUP BY PartNum, Plant |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment