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 2000 Forums
 SQL Server Development (2000)
 Query for event behavior over time

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-06-08 : 08:01:44
Wen writes "I'm looking to track client behavior over time

Here is the basic table structure

CREATE TABLE tbEventLog (ClientID int,
EventType int,
EventResult int,
EventTIme int)

What I'm interested in doing is for each ClientID that exhibits a Result of 'FAILED' for a given EventType, did it have a Result of 'SUCCESS' within the next x hours.


SQL 2000 SP3a on Windows Enterprise Server 2003 RTM"

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2004-06-08 : 08:13:54
Jeff Smith's article on detecting streaks is just what the doctor ordered.

OS
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-06-08 : 08:13:57
this should be close.......

select a.clientid from tbEventLog a
inner join tbEventLog b on a.clientid = b.clientid and a.eventtype = b.eventtype
where a.eventresult = 'failed'
and b.eventresult = 'success'
and datediff(hh,a.eventtime,b.eventtime) > x

you may need to re-order the datediff a.eventtime,b.eventtime entries
Go to Top of Page
   

- Advertisement -