e.g.declare @t table (devid int, _read int, read_dt DATE)insert into @t (devid, _read, read_dt) values--DEVID / READ / READ_DT(1, 500 , '12-20-2014'),(1, 425 , '11-21-2014'),(1, 300 , '10-19-2014'),(2, 800 , '12-17-2014'),(2, 745 , '11-16-2014'),(2, 600 , '10-21-2014')select DEVID, _read, read_dt, _read - lag(_read) over (partition by devid order by read_Dt) as difffrom @t
produces:DEVID _read read_dt diff1 300 2014-10-19 NULL1 425 2014-11-21 1251 500 2014-12-20 752 600 2014-10-21 NULL2 745 2014-11-16 1452 800 2014-12-17 55