mysql - Grouping into interval of 5 minutes within a time range -


i have difficulties mysql commands want do.

select a.timestamp, name, count(b.name)  time a, id b  a.user = b.user   , a.id = b.id   , b.name = 'john'   , a.timestamp between '2010-11-16 10:30:00' , '2010-11-16 11:00:00'  group a.timestamp 

this current output statement.

timestamp            name  count(b.name) -------------------  ----  ------------- 2010-11-16 10:32:22  john  2 2010-11-16 10:35:12  john  7 2010-11-16 10:36:34  john  1 2010-11-16 10:37:45  john  2 2010-11-16 10:48:26  john  8 2010-11-16 10:55:00  john  9 2010-11-16 10:58:08  john  2 

how group them 5 minutes interval results?

i want output like

timestamp            name  count(b.name) -------------------  ----  ------------- 2010-11-16 10:30:00  john  2 2010-11-16 10:35:00  john  10 2010-11-16 10:40:00  john  0 2010-11-16 10:45:00  john  8 2010-11-16 10:50:00  john  0 2010-11-16 10:55:00  john  11  

this works every interval.

postgresql

select     timestamp time zone 'epoch' +     interval '1 second' * round((extract('epoch' timestamp) / 300) * 300)      timestamp,     name,     count(b.name) time a, id  … group  round(extract('epoch' timestamp) / 300), name 


mysql

select     timestamp,  -- not sure     name,     count(b.name) time a, id  … group  unix_timestamp(timestamp) div 300, name 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -