如下表结构id, 日期,    值
1   2011/03/01  1
1   2011/03/04  5
2   2011/03/02  8
2   2011/03/06  4求sql语句得出如下结果
id, 日期,    值
1 2011/03/04 5
2 2011/03/06 4

解决方案 »

  1.   


    select *
    from tb t
    where not exists (select 1 from tb where id = t.id and 日期 > t.日期)
      

  2.   

    select t.* from tb t where not exists(select 1 from tb where id = t.id and 日期 > t.日期)select t.* from tb t where 日期 = (select max(日期) from tb where id = t.id)