SQL 面试题# JobHunting - 待字闺中
I*9
1 楼
2 variables in table1 showing all records of transactions each customer
makes. one customer (usedid 001) may purchase same products (productid Q909)
several times.
table1:
userid productid
001 Q909
001 Q909
001 Q908
002 Q101
Question: use SQL to calculate how many customers purchase only 1 type of
product, 2 types of products, 3...and so on.
for example: if there were 694 unique userid who purchased only 1 unique
productid, 900 unique userid purchased only 2 unique productid, we want to
get below table:
number_of_type_product_purchased number_of_customer
1 694
2 900
3 200
请高手指点吧
makes. one customer (usedid 001) may purchase same products (productid Q909)
several times.
table1:
userid productid
001 Q909
001 Q909
001 Q908
002 Q101
Question: use SQL to calculate how many customers purchase only 1 type of
product, 2 types of products, 3...and so on.
for example: if there were 694 unique userid who purchased only 1 unique
productid, 900 unique userid purchased only 2 unique productid, we want to
get below table:
number_of_type_product_purchased number_of_customer
1 694
2 900
3 200
请高手指点吧