Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tricky time-based filtering problem

Status
Not open for further replies.

ookete

Programmer
Oct 5, 2004
180
0
0
US
I have a view with a datetime field and I need to eliminate rows that occur within 2 seconds of the first. So for example:

ID AcctID EntryTime
1 1 1/2/2010 10:00:00.000
2 1 1/2/2010 10:30:00.000
3 1 1/2/2010 10:30:00.500 *
4 1 1/2/2010 10:30:01.200 *
5 2 1/2/2010 10:30:01.000
6 2 1/2/2010 11:05:02.500

The (*) rows are the ones in question. I need to filter out ID 3 and 4 because they are within two seconds of ID 2, grouped by AcctID.

I would love to figure this out using set techniques instead of looping or cursors. Any thoughts?
 
Thank you. I think you left out the blogspot blog name in your link, the link gives me a 404.
 
You're right, I copied it from the mentioned MSDN thread and perhaps didn't copy the full URL. It's

Though I've been thinking that your problem may be easier and all you need is a self-join based on RowNumber RowNumber+1.

In any case, reading this blog will be helpful.

PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top