That should be:

having
        sum(products.id) > 1


On 8/22/07, Rick Root <[EMAIL PROTECTED]> wrote:
> Without knowing a little more about the structure... try something
> like this (I used pseudo code, not actual field names / table names,
> but you should get the idea)
>
> I don't know for sure if this will work but it should drive you in the
> right direction.
>
> First you need a query that produces a list of customer/order/category
> combinations that sums the number of products ordered in each
> category.
>
> Then you restrict the results to return only rows where the sum of
> products per category is more than 1.
>
> select
>        orders.customer_id,
>        orders.id,
>        categories.id,
>        sum(products.id)
> from orders
>        inner join order_products on order_products.id=orders.id
>        inner join products on products.id=orders.id
>        inner join categories on categories.id=products.id
> group by
>        orders.customer_id,
>        orders.id
> having
>        sum(categories.id) > 1
>


-- 
Rick Root
Check out CFMBB, BlogCFM, ImageCFC, ImapCFC, CFFM, and more at
www.opensourcecf.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:286893
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to