I tested the theory that ProdTable.RealDate should be equal to MAX(InventTrans.DateFinancial), and across all 270k ProdTable records in my business database where the order was Ended, they are identical. Here's a quick query I used to look for cases where they were different, and 0 records returned. select p.[PARTITION], p.DATAAREAID, p.PRODID, p.REALDATE, MAX(t.DATEFINANCIAL) AS DATEFINANCIAL from PRODTABLE p join INVENTTRANSORIGIN o ON o.[PARTITION] = p.[PARTITION] AND o.DATAAREAID = p.DATAAREAID AND o.REFERENCEID = p.PRODID AND o.REFERENCECATEGORY = 2 join INVENTTRANS t ON t.[PARTITION] = o.[PARTITION] AND t.DATAAREAID = o.DATAAREAID AND t.INVENTTRANSORIGIN = o.RECID where t.STATUSISSUE MAX(t.DATEFINANCIAL) -- where different
↧