Finding records within a 5 min time interval in SQL
- by Mellonjollie
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.