作者twyes1688 (twyes1688)
看板Database
标题Re: [SQL ]MAX()其他相依的栏位资料
时间Wed Mar 27 10:57:19 2013
我想你的问题可能是
查出 id,max(value)後要再找出这个资料的 date,note
select b.*
from(
select id,max(value) as max_value
from table
group by id) a left join table b
on a.id=b.id and a.max_value=b.valus
但一个id的max(value) join 到 B後可能会有两笔上
(一个id有可能有2笔以上相同的最大值)
※ 引述《folus (folus)》之铭言:
: 请教各位高手:
: 我目前遇到一个问题,直接看 SQL 吧
: select id,max(value) from table group by id
: table 栏位共有 id,value,date,note
: 我要如何查询相依於结果 id,max(value)的其他栏位呢?
: 感谢高手协助
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.139.23.140