Re: [SQL ] 汇总函数抓主键

楼主: cutekid (可爱小孩子)   2014-07-01 14:38:18
select t1.商品,t1.价格
from table as t1,(
select max(价格) as maxPrice from table
) as t2
where t1.价格 = t2.maxPrice
※ 引述《firerycon (不是保育类)》之铭言:
: 上学期期末考怎么想都做不出来
: 题目要我们利用汇总函数里面的Max和min
: 比较并显示最贵的商品
: SELECT MAX(price)
: FROM...
: 比较之后结果只显示最大的那个价格(数字)
: 请问我要怎么同时抓出抓出最贵的商品(ID或名称)和价钱并显示出来?

Links booklink

Contact Us: admin [ a t ] ucptt.com