金蝶的一道SQL笔试题

2014-11-23 21:31:48 · 作者: · 浏览: 25

表结构如下
————————————
Buyer Name Quantity
A 甲 2
B 乙 4
C 丙 1

A 丁 2
B 丙 5


请给出所有购入商品为两种或两种以上的购物人记录
select Buyer as 顾客,count(name) as 商品种类数 from table group by Buyer having count(name)>=2
select * from table where Buyer in (select Buyer from table group by Buyer having count(name)>=2)