Jump to content

Recommended Posts

Hi All,

 

does anyone know any efficient way to group mysql data into 'bins' of time interval? What i want is to show a profile over time of how many times someone's page has been visited. Each time someone visits, they get added to a mysql database. So it's basically a collection of timestamps.

 

I'd like to be able to say

January: 10

Feb: 12

March: 5

 

etc etc....

 

Would it be best as part of the mysql query? or does php have some magic up its sleeve?

 

Thanks all!

GROUP BY sort the results of an aggregate function such as count into groups based on charactaristics of the results. In your case, a characteristic of a timestamp is the month. MySQL understands this and can sort by year, month, day, hour, minute, etc.

 

More info

 

The query MatthewJ posted should work for what you are trying to accomplish.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.