Im trying to calc the average, between a specific date/time, of the difference between the current field and the previous field. At present ive got a query which displays this but im unsure how i can now filter this such that i can get the average of the 'Diff' column between a specific date/time. (Apologies in advance for my sql skill, or lack off)
SELECT S.Pair, S.Date, S.Time, S.Bid, S.Time, ABS(S.Bid - T.Bid) as 'Diff' FROM dbo.Data as S CROSS APPLY ( SELECT TOP 1 T.Bid FROM dbo.Data as T WHERE T.Id > S.Id ) as T
Any pointers would be appreciated.