一个表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)
我验证了一下结果是对的,但是我不太明白,请哪位高手讲解一下。
解决方案 »
- 关于mysql order索引问题
- 求一SQL语句,查询一个库中所有表中所有字段,只要符合关键字,就输出
- mysql插入中文 出错
- SQL 语句求助
- fulltext 相关性的问题
- postgres的编码问题
- why??????????gao fen qiu zhu!!!help me please
- >请问谁有 E-book:MYSQL权威指南(第二版) CHINA-PUB.COM的电子版?? <
- ASP如何使用MSSQL
- 用Mysql编过桌面应用程序的兄弟们,你们的Mysql应用程序在启动时,是否一定要手动启动Mysql Server呢?我的应用程序为什么一启动就要我填写一个对话框,并启动Mysql Server,fo=
- 菜鸟 请教MySql问题
- 在繁体WINXP下,客户端用ODBC为何连不上MYSQL服务器啊
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最大的那项