Select and group rows in summary by hour

I have a table containing view/click records. The time is stored in a unix timestamp and I need to be able to pull out all of them within the specific month/day (based off of timestamps), but more importantly and the part I don't know how to do is group them by hour. I need to be able to do this in a single query rather than looping through each hour.

Database is MySQL, language is PHP.

Answers


select hour(somedate), count(*) from yourtable group by hour(somedate)

If you need all three:

select month(somedate), day(somedate), hour(somedate), count(*) from yourtable group by month(somedate), day(somedate), hour(somedate)

Need Your Help

Creating a custom control in WPF

c# wpf custom-controls

Having custom control's content defined like this:

Javascript focus on browse button of file input

javascript file input focus

I am trying to focus on the browse button of the file input control.