This must be a common thing to want to do, but I’m stuck.
I have some data that could be simplified like this:
id user unixtime
-----------------------
1 dave 1335312057
2 dave 1335312058
3 steve 1335312128
etc.
So far, I have only needed to aggregate by day, so I’ve been using:
SELECT
UNIX_TIMESTAMP(DATE(FROM_UNIXTIME(unixtime))) AS time,
count(c.user) AS count
FROM core c
GROUP BY DATE(FROM_UNIXTIME(unixtime))
I’ve tried using CONCAT with DATE and HOUR, but can’t quite get it working as expected – any ideas?
if you want the hour as a unix timestamp, wrap this query to get it:
Note: Used
the_prefix on column names to avoid problems with reserved words