We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Count Mysql result by hour

babak62
babak62 asked
on
Medium Priority
532 Views
Last Modified: 2012-05-11
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'
Comment
Watch Question

Aaron TomoskyDirector, SD-WAN Solutions
CERTIFIED EXPERT

Commented:
Datepart(hour, reg_timestamp) as reghour

Group by reghour
Data Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

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
Aaron TomoskyDirector, SD-WAN Solutions
CERTIFIED EXPERT

Commented:
You forgot the comma before datepart
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.