Paste Description for pb
MySQL and groups with HAVING
- pb
- Tuesday, July 10th, 2007 at 11:31:49am MDT
- Works, kind of...
- SELECT distinct area_code as AC, phone_num as PN, ord_date, store_num
- FROM `orders_p`
- GROUP BY AC, PN
- HAVING min(ord_date)>='20070101' and min(ord_date)<='20070128'
- Returns empty set... (?!)
- SELECT count(*), ord_date, store_num
- FROM `orders_p`
- GROUP BY store_num
- HAVING min(ord_date)>='20070101' and min(ord_date)<='20070128'
- Hoping to get something like:
- count(*) ord_date store_num
- --------- --------- -----------
- 35 20070101 1
- 24 20070101 2
- 36 20070101 3
- [etc.]
- (The value in ord_date isn't meaningful and probably can be removed from the columns.)
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.