In article <[EMAIL PROTECTED]>,
John Mistler <[EMAIL PROTECTED]> writes:

> I need help coming up with the following query:
> My table:

> +-------------+----------------------+
> | rowID       | dateOfPurchase       |
> +-------------+----------------------+
> |   1         | '2004-1-17 08:00:00' |
> +-------------+----------------------+
> |   4         | '2004-1-17 08:03:20' |
> +-------------+----------------------+
> |   1         | '2004-1-17 08:05:45' |
> +-------------+----------------------+
> |   2         | '2004-1-17 08:07:11' |
> +-------------+----------------------+
> |   1         | '2004-1-17 08:09:03' |
> +-------------+----------------------+
> |   4         | '2004-1-17 08:11:56' |
> +-------------+----------------------+
> |   1         | '2004-1-17 08:13:24' |
> +-------------+----------------------+

> I would like to return all rowIDs that do not exist more than 3 times in the
> 08:00:00 - 09:00:00 hour of date '2004-1-17'.

SELECT rowID
FROM tmp
WHERE dateOfPurchase BETWEEN '2004-01-17 08:00:00' AND '2004-01-17 09:00:00'
GROUP BY rowID
HAVING count (*) <= 3


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to