Group records by time

后端 未结 2 888
伪装坚强ぢ
伪装坚强ぢ 2020-12-18 07:44

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

2条回答
  •  执笔经年
    2020-12-18 08:11

    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.

提交回复
热议问题