怎么样使用count来比较大小 2!!! (100分)

  • 主题发起人 主题发起人 DancingAgain
  • 开始时间 开始时间
D

DancingAgain

Unregistered / Unconfirmed
GUEST, unregistred user!
Dearall:

I have the question to get helps from you!

given two relations
1. product(maker, model, type)
maker model type
a 1001 pc
a 1002 pc
a 1003 pc
b 1004 printer
b 1005 pc
c 1006 pc
.
.
2.pc(model, speed)
model speed
1001 133
1002 166
1003 166
1004 123
....

Suppose model is unique for each row, use sql to represent
find the makers of pc'c with at least three different speeds?

I don't know how to count the record line:
i give the statement(this is error!!)

select maker from product,pc
where product.model = pc.model
and product.type='pc'
group by maker
having count(distinct speed) >=3;

Thank you


 
error?i can't found it.
wait......
 
试试看这样写:
Select Maker, Cnt From
(select maker,count(distinct speed) as Cnt from product,pc
where product.model = pc.model
and product.type='pc'
group by maker) A
Where Cnt >= 2

 
dear all:
Thank you for your answers!

In fact, I had known some possible answers which are supported by oracle!
But now I need to use MySql which cannot support some extended Sql statement!
such as :
select maker from product, pc
where product.model=pc.model
and product.type='pc'
group by maker
having count(distinct speed) > 3; // this statement cannot be supported by
//mysql, only having count(speed) > 3 is ok, but this statement have totally
//different meanings


Thank you for your help!

 
try this:
select maker from product
where model in
select modelNum from
(select count(speed) as modelNum
from pc
group by model
)
where modeNum>=3
 
having count(distinct speed) >=3;
??
speed
133
166
166
123
 
提问者:
如果你还要继续讨论请定期提前你的帖子,如果不想继续讨论请结束帖子。
请认真阅读大富翁论坛规则说明 http://www.delphibbs.com/delphibbs/rules.asp
 
接受答案了.
 
后退
顶部