Finding records within a 5 min time interval in SQL

Posted by Mellonjollie on Stack Overflow See other posts from Stack Overflow or by Mellonjollie
Published on 2012-11-02T04:46:27Z Indexed on 2012/11/02 5:00 UTC
Read the original article Hit count: 154

Filed under:
|
|
|

I have a table with over 100,000 rows that contain the following columns: ID, Time, and Boolean.
The time column tracks time down to the second.
I need a query that will find all instances of Boolean = 1 for every 5 minute interval of time from the start of the table to the end, then group the count by time interval.

The table represents 4 hours of data, so I should get 48 rows of results.
I'm using MS SQL Server.

I've tried a few approaches, but the time interval logic is giving me a hard time.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server