This query totals the inventory value for inventoried parts for each GL Asset Account as of a specific point in history.

None. This is a selection query and no data is modified in the running of it.

<code sql> DECLARE @HistoricDate DATETIME; SET @HistoricDate = '12/31/09 23:59'; DECLARE @LastUnitCost TABLE(PartID INT PRIMARY KEY, LastInvLogID INT, UnitCost FLOAT); INSERT INTO @LastUnitCost (PartID, LastInvLogID) SELECT IL.PartID, MAX(IL.ID) ID FROM InventoryLog IL

       LEFT JOIN Journal J ON (J.ID = IL.ID)

WHERE (IL.ID > 0) AND (IL.PartID IS NOT NULL) AND (J.StartDateTime

You could leave a comment if you were logged in.