Re: need some SQL help



"Hugo Kornelis" <hugo@xxxxxxxxxxxxxxxxxxxxxx> wrote in message

> The following is untested since I don't have MySQL. It *should* work on
> all ANSI-compliant databases. It should also take no more than one
> single pass over the data in the table (if the optimizer in your
> database is worth it's salt, that is).
>
> SELECT customer_id
> FROM (SELECT customer_id, order_type
> FROM orders
> WHERE order_type IN (3, 4)
> GROUP BY customer_id, order_type
> HAVING ( order_type = 3 AND SUM(amount) > 100)
> OR ( order_type = 4 AND SUM(amount) > 200) ) AS derived
> GROUP BY customer_id
> HAVING COUNT(*) = 2
>

hugo, it worked perfectly! Thanks for taking the time to help me. Much
appreciated.


.