tags:

views:

316

answers:

1
+2  Q: 

SQLITE group by

I use the sql below in sqlite to group by time intervals. The first is group by day and the second group by hour:

select strftime('%Y-%m-%dT%00:00:00.000', date_time),line, count() from entry group by strftime('%Y-%m-%dT%00:00:00.000', date_time)

select strftime('%Y-%m-%dT%H:00:00.000', date_time),line, count() from entry group by strftime('%Y-%m-%dT%H:00:00.000', date_time)

How do I group by 10 minutes interval

+1  A: 
 select ... from entry
 group by strftime('%Y%m%d%H0', date_time) + strftime('%M', date_time)/10;
Alex B
You know that does not answer my question?
yaza
Oops, yes, you are right!
Alex B
OK, fixed the multiplier, this should work.
Alex B