题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
--解决方案(1) SELECTc.customer_id, c.customer_nameFROMOrdersoLEFTJOINCustomerscONo.customer_id=c.customer_idGROUPBYc.customer_idHAVINGSUM(product_name='A') *SUM(product_name='B') >0ANDSUM(product_name='C') =0ORDERBYc.customer_id--解决方案(2) SELECTDISTINCTc.customer_id, customer_nameFROMOrdersoJOINCustomerscONo.customer_id=c.customer_idWHEREc.customer_idIN (SELECTcustomer_idFROMOrdersWHEREproduct_name='A') ANDc.customer_idIN (SELECTcustomer_idFROMOrdersWHEREproduct_name='B') ANDc.customer_idNOTIN (SELECTcustomer_idFROMOrdersWHEREproduct_name='C')