我有个表tmp.id = 10
表2 score(id , score, date)
如
id , score, date
10 100 2013-10-29
10 100 2013-10-22
10 100 2013-10-21
15 100 2013-10-29
15 100 2013-10-22
15 100 2013-10-21怎么快速提取 tmp.id = 10在表二的最新分数呢?
求教,数据量很大很大,90W条tmp.id的数据
表2 score(id , score, date)
如
id , score, date
10 100 2013-10-29
10 100 2013-10-22
10 100 2013-10-21
15 100 2013-10-29
15 100 2013-10-22
15 100 2013-10-21怎么快速提取 tmp.id = 10在表二的最新分数呢?
求教,数据量很大很大,90W条tmp.id的数据
select a.*
from score a,
(select id ,max(date) edate from score group by id) b
where a.id = b.id and a.date = b.edate and a.id = 10
(select id ,max(date)edata from score a where a.id=10 group by id)a
感觉不用这样吧?
直接这样不就OK了
select b.* from (select id ,max(date) edate from score group by id) b where b.id = 10