Hi
I'm querying a table and looking at the difference between timestamps.
The current table has Document_ID, Status, [TimeStamp]
I'm running a query which adds the next time stamp for that document id
so im doing a self join sub query to get that value which works great.
SELECT Min(a2.[TimeStamp])
FROM ai_audit_trail a2
a2.doc_id = a.doc_id
AND a.[TimeStamp] < a2.[TimeStamp]
The problem is i'm getting instances where the timestamp is exactly the same so instead of looking at following row it slooking at the following row where its different :(
DateBetweenStatus NextTimeStamp Doc_ID TimeStamp Status
0 2007-01-29 13:55:08.297 351346 2007-01-29 13:55:06.140 Changed Owner to : 2nd Checker
9962 2007-02-05 11:57:27.640 351346 2007-01-29 13:55:08.297 Changed Owner to : 2nd Checker
9962 2007-02-05 11:57:27.640 351346 2007-01-29 13:55:08.297 Changed Status to : INTECH ENTRY COMPLETE