关于having count 的问题,请高手赐教,谢谢!
查询一个业务员至少卖三种以上商品的业务员编号及商品编号create table shop_xs
(
id number(3) not null, 商品编号
sale number(5),
quantity number(5),
date2 date,
ywid number(3) not null, 业务员编号
foreign key(id) references shop_jb,
foreign key(ywid) references shop_yw
数据
ID SALE QUANTITY DATE2 YWID
1 101 3000 100 1992-5-10 2
2 102 6000 50 2005-3-25 3
3 102 6000 10 2005-3-26 1
4 103 2010 15 2008-7-14 4
5 104 7000 150 2009-6-28 5
6 101 3000 100 1992-5-10 2
7 102 3000 100 1992-5-10 2
8 101 3000 100 1992-5-10 3
9 103 3000 100 1992-5-10 3
10 101 3000 100 1992-5-10 4
11 102 3000 100 1992-5-10 4
select DISTINCT a.id,a.ywid from shop_xs a join shop_xs b on a.id <> b.id and a.ywid = b.ywid
group by a.id,a.ywid
having count(a.ywid)>=3
为什么我查询的结果没有数据啊,急!请大侠赐教!!!谢谢