var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Query Help
Hi, I have a db which tracks orders. I would like a query which lists the date and time of the most orders in a given calendar month.
date time number
13/4/10 09:00 - 10:00 150
11/4/10 10:00 - 11:00 148
Any Ideas ???
Here you simply use the DATE_FORMAT function on the date field. As follows:
SELECT DATE_FORMAT(fieldname, '%d/%m/%y %H') as timeofday, COUNT(1) AS RESULT
GROUP BY DATE_FORMAT(fieldname, '%d/%m/%y %H')
ORDER BY COUNT(1) DESC;
The timeofday will return entries as follows:
13/04/10 09 - number of occurences
13/04/10 10 - number of occurrences
The 09 and 10 represent the hour of the day in which these occurred and the order by to provide them in the most to the least.
Last edited by it-iss.com; 04-15-10 at 18:11.
Reason: Incomplete SQL