一个表shop含三个属性:article(商品),dealer(交易者),price(价格)
现在“对每种商品,找出最贵的价格的交易者”答案如下:select article,dealer,price
from shop s1
where price=(select max(s2.price)
from shop s2
where s1.article=s2.atricle)
我验证了一下结果是对的,但是我不太明白,请哪位高手讲解一下。
现在“对每种商品,找出最贵的价格的交易者”答案如下:select article,dealer,price
from shop s1
where price=(select max(s2.price)
from shop s2
where s1.article=s2.atricle)
我验证了一下结果是对的,但是我不太明白,请哪位高手讲解一下。
select * from shop where price=(select max(price) from shop)
quto:select article,dealer,price
from shop s1
where price=(select max(s2.price)
from shop s2
where s1.article=s2.article)
其中 where s1.article=s2.article 相当于对article进行分组 然后找出分组中price最大的那项