I'm working on a query where I have to find 3 or more orders on a part that will have multiple date ranges. The problem I'm having is that it looks like the query isn't looking at the date ranges specifically...it's looking at a complete range of dates.
SELECT partnumber, count(orders.partorderid) as numberoforders
FROM orders
WHERE(orderdate between '2013-10-07' and '2013-10-13') or (orderdate between '2013-10-14' and '2013-10-20')
GROUP BY partnumber
HAVING COUNT(partorderid) > 2
The query returns the numberoforders between 10/07-10/20, not 10/07-10/13 and 10/14-10/20???