I have a table containing a datetime column and some misc other columns. The datetime column represents an event happening. It can either contains a time (event happened at
Give this a try:
select datetime((strftime('%s', time) / 900) * 900, 'unixepoch') interval, count(*) cnt from t group by interval order by interval
Check the fiddle here.