Count Mysql result by hour

Hi this is my query which counts my new users registered per day.  I am trying to find out to make this to show results per hour also whitin 24 hours show how many users signed up in which hour like 11:00 10 uers and 12:00 15 etc...
Is there anyway to change this to accomplish thisi task.  Then again thanks for the help

SELECT COUNT(t_user.USERID)
FROM
t_user
WHERE
`REG_TIMESTAMP` BETWEEN '2011-04-20 00:00:00' AND '2011-04-20 23:59:59'
babak62Asked:
Who is Participating?
 
SharathConnect With a Mentor Data EngineerCommented:
try this.
SELECT HOUR(REG_TIMESTAMP), 
         COUNT(t_user.USERID) 
    FROM t_user 
   WHERE `REG_TIMESTAMP` BETWEEN '2011-04-20 00:00:00' AND '2011-04-20 23:59:59' 
GROUP BY HOUR(REG_TIMESTAMP)

Open in new window

0
 
Aaron TomoskySD-WAN SimplifiedCommented:
Datepart(hour, reg_timestamp) as reghour

Group by reghour
0
 
babak62Author Commented:
Thanks for the answer I did like this

SELECT COUNT(t_user.USERID)
Datepart(hour, reg_timestamp) as reghour
FROM
t_user
WHERE
`REG_TIMESTAMP` BETWEEN '2011-04-20 00:00:00' AND '2011-04-20 23:59:59'
Group by reghour

and this was the error

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(hour, reg_timestamp) as reghour
FROM
t_user
WHERE
`REG_TIMESTAMP` BETWEEN ' at line 2
0
 
Aaron TomoskySD-WAN SimplifiedCommented:
You forgot the comma before datepart
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.