On 22-Aug-2001 Johan Nilsson wrote:
> Hi,
>
> 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. 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;
Regards,
--
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)
---------------------------------------------------------------------
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