This is not what you wrote twice in the original post.-- Prepare sample data. Not part of solution, only to mimic your environment.DECLARE @Sample TABLE (PriceCalcID INT, Date DATETIME, Price MONEY, ItemID INT)SET DATEFORMAT YMDINSERT @SampleSELECT 2000, '2006-12-12', 3000, 100 UNION ALLSELECT 2488, '2007-10-11', 2800, 100 UNION ALLSELECT 3100, '2008-08-07', 2500, 100 UNION ALLSELECT 3000, '2006-12-12', 1000, 200 UNION ALLSELECT 3488, '2007-10-11', 1800, 200 UNION ALLSELECT 4100, '2008-08-07', 1500, 200-- Solution starts here with stage source dataDECLARE @Stage TABLE (RowID INT IDENTITY(1, 1), PriceCalcID INT, ItemID INT)INSERT @StageSELECT PriceCalcID, ItemIDFROM @SampleORDER BY ItemID, Date-- And here is the final querySELECT sa1.PriceCalcID, sa1.Date, sa1.Price, sa1.ItemID, sa1.Price - sa2.Price AS DiffFROM @Stage AS st1LEFT JOIN @Stage AS st2 ON st2.ItemID = st1.ItemID AND st2.RowID + 1 = st1.RowIDLEFT JOIN @Sample AS sa1 ON sa1.PriceCalcID = st1.PriceCalcID AND sa1.ItemID = st1.ItemIDLEFT JOIN @Sample AS sa2 ON sa2.PriceCalcID = st2.PriceCalcID AND sa2.ItemID = st2.ItemIDORDER BY st1.RowID
E 12°55'05.25"N 56°04'39.16"