>> Is it possible for me to do a SELECT COUNT(*) and GROUP BY the 
>answers based
>> on a INTERVAL e.g. HOUR?
>> 
>> the e.g. table data:
>> +------------+
>>| id | time  |
>> +------------+
>>|  1 | 08:30 |
>>|  2 | 09:30 |
>>|  3 | 09:31 |
>>|  4 | 09:32 |
>> +------------+
>> 
>> The answer I want from the e.g. data above if using INTERVAL HOUR
>> +----------+
>>| COUNT(*) |
>> +----------+
>>|       1  |
>>|       3  |
>> +----------+
>> 
>> It it's possible, how do i write it? or if it's not possible, 
>what can I do
>> instead?
>> 
>
>SELECT HOUR(time) as hour,count(*) as cnt FROM foo GROUP BY hour;
>

Thanks, but I wrote a bad test data =(

+-----------------------+
| id | dateTime         |
+-----------------------+
|  1 | 2000-01-01 08:30 | <- i.e. 2000
|  2 | 2000-01-01 08:31 | <- i.e. 2000
|  3 | 2001-01-01 08:30 |
|  4 | 2001-01-01 09:31 |
|  5 | 2001-01-01 09:32 |
|  6 | 2001-01-01 09:32 |
+-----------------------+

+----------+
| COUNT(*) |
+----------+
|       2  | <- same hour as below but year 2000
|       1  | <- same hour as above but year 2001
|       4  | 
+----------+

Regards,
Johan Nilsson
Software Developer
BeCon Mobile Internet AB, Sweden
Web: http://www.beconmobile.com
E-Mail: [EMAIL PROTECTED]
Office: +46 457 44184
Cellular: +46 709 798897

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to