CREATE TABLE A
( [购物人] NVARCHAR(10),
[商品名称] NVARCHAR(10),
[数量] INT
)
INSERT INTO A
SELECT 'A','甲',2
UNION ALL SELECT 'B','乙',4
UNION ALL SELECT 'C','丙',1
UNION ALL SELECT 'A','丁',2
UNION ALL SELECT 'B','丙',5
UNION ALL SELECT 'C','丙',5
查询出购买了2(包括)种以上商品的购物人
SELECT [购物人] FROM A GROUP BY [购物人] HAVING COUNT(DISTINCT [商品名称])>1