Question: Show all product names and the number of customers having an order on each product.
Schema: create table order_items (product_id varchar, order_id varchar, PRIMARY KEY (product_id)); create table orders (order_id varchar, PRIMARY KEY (order_id)); create table products (product_name varchar, product_id varchar, PRIMARY KEY (product_name))
SQL: select t2.product_name, count(*) from order_items as t1 join products as t2 on t1.product_id = t2.product_id join orders as t3 on t3.order_id = t1.order_id group by t2.product_name