Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Time Range of Two Events

Author  Topic 

Dasman
Yak Posting Veteran

79 Posts

Posted - 2011-06-07 : 12:22:08
Hello Everyone,

So I am giving a few rows of the table i have:
EventB 2005-09-14 09:36:04.523 2
EventA 2005-09-14 09:37:20.370 2
EventB 2005-09-14 09:37:38.870 2

Now lets say I only want to see when a EventB event happens AFTER a EventA happens and within 30 - 60 seconds of the Event A ending.
The timing would be done with the second column.

Has anybody know the commands that would help?

Thanks,
Dasman

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2011-06-07 : 19:04:46
[CODE]select t2.Event
from MyTable t1
inner join
MyTable t2
on t1.Event = 'EventA'
and t2.Evert = 'EventB'
and DateDiff(second, t1.EventTime, t2.EventTime) between 30 and 60[/CODE]

=======================================
Elitism is the slur directed at merit by mediocrity. -Sydney J. Harris, journalist (1917-1986)
Go to Top of Page

Dasman
Yak Posting Veteran

79 Posts

Posted - 2011-06-08 : 00:34:19
What are the Event Time variables? I am only given start and stop times in this format
2005-09-14 09:36:04.523
so date then time all in one entry and a column of the start times and stop times.



SQL Should be Fun!
Go to Top of Page
   

- Advertisement -