Count the number of distinct products each customer ordered.
select count (t3.product_id) from customers as t1 join customer_orders as t2 on t1.customer_id = t2.customer_id join order_items as t3 on t2.order_id = t3.order_id group by t1.customer_id
Find customers who have bought at least three distinct products.
select distinct * from customers as t1 join customer_orders as t2 on t1.customer_id = t2.customer_id join order_items as t3 on t2.order_id = t3.order_id group by t1.customer_id having count (distinct t3.product_id) >= 3
What are their names?
select distinct t1.customer_name from customers as t1 join customer_orders as t2 on t1.customer_id = t2.customer_id join order_items as t3 on t2.order_id = t3.order_id group by t1.customer_id having count (distinct t3.product_id) >= 3