我有个表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的数据

解决方案 »

  1.   


    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
      

  2.   

    select * from 
    (select id ,max(date)edata from score a where a.id=10 group by id)a
      

  3.   

    补充一下,score 的数据量也很大, 比如180w条
      

  4.   

    很佩服,就是这种。我的想法还有用in的
    感觉不用这样吧?
    直接这样不就OK了
    select b.* from (select id ,max(date) edate from score group by id) b where b.id = 10