larrydavid
Programmer
Hello,
Is it possible to determine the Min and Max timestamp intervals for records as they are inserted? The table accepts inserts only, no updates and produces this output:
So, for user K33333 I would see the time interval between record ID 2 and ID 4. There are many records besides this for a day, but the table is truncated and archived each evening so there is always one day's worth of data only. So, for this user I would need the minimum and maximum intervals over the course of a day. I've been trying to put my head around it and have this so far, but it is only giving my an overall time lapse in minutes:
So, as you can see, I'm getting the MAX overall interval, but not the intervals between each insert. Am I on the right track? Any help with this would be greatly appreciated as always.
Thanks,
Larry
Is it possible to determine the Min and Max timestamp intervals for records as they are inserted? The table accepts inserts only, no updates and produces this output:
Code:
ID TxNo UserID TimeStamp
1 X1866246100 i22222 2011-03-07 05:59:37.863
2 X1884627200 K33333 2011-03-07 06:03:35.740
3 X1878488900 d44444 2011-03-07 06:04:10.520
4 X1885453100 K33333 2011-03-07 06:04:29.097
5 X1878488901 d44444 2011-03-07 06:04:45.503
So, for user K33333 I would see the time interval between record ID 2 and ID 4. There are many records besides this for a day, but the table is truncated and archived each evening so there is always one day's worth of data only. So, for this user I would need the minimum and maximum intervals over the course of a day. I've been trying to put my head around it and have this so far, but it is only giving my an overall time lapse in minutes:
Code:
Select Userid, max(TimeStamp) as mTime
into #Temp1
from CSDBBRDFC001.Hope.dbo.RealTimeProd
Where convert(varchar, TimeStamp, 112) = convert(varchar, getdate(), 112)
Group by UserID
Select a.*, b.FirstName + ' ' + b.LastName as UserName, Datediff(minute, a.mTime, getdate()) as Lapse_Time_in_Minutes
into #Temp2
from #Temp1 a LEFT JOIN [User] b
On upper(a.UserID) = upper(b.ID)
Order by Datediff(minute, a.mTime, getdate()) Desc
Select * from #Temp2
So, as you can see, I'm getting the MAX overall interval, but not the intervals between each insert. Am I on the right track? Any help with this would be greatly appreciated as always.
Thanks,
Larry