202k views
4 votes
create a query that returns a list of manufacturers (manufacturer_id), the number of unique customers who have placed an order with that manufacturer (customer count), and the number of unique products that have been ordered from that manufacture (product count). Limit your results to manufacturers who have sold to at least 100 different customers and at least 10 different products

User NcRubert
by
5.7k points

1 Answer

7 votes

Answer:

select manufacturer_id from manufacturer where (DISTINCT(customer)==customer count) AND (DISTINCT(product)== product count) and (no_of_Customer>=100)and(no, of products>=10).

Step-by-step explanation:

In the above distinct is used to find the unique customer and product. And since the conditions must be fulfilled and all of them, hence AND operator has been used to join them all. select and where usage is self explanatory and also checked are the least number of products and customers. Product count and customer count have been used as mentioned.

User Johnny Chu
by
5.5k points