select top 1 * from tabel1 where name='aa' order by date desc

解决方案 »

  1.   

    select top 1 * from tabel1 where name='aa' order by date desc或:select * from tabel1 where name='aa' and date=(select max(date) from table1)
      

  2.   

    select top 1 * from tabel1 where name='aa' order by date desc
    是可以的,而后面那一条
    select * from tabel1 where name='aa' and date=(select max(date) from table1)
    有问题吧。
    应该是
    select * from tabel1 where date=(select max(date) from table1
    where name='aa')
      

  3.   

    但我还有个小问题?
    如果我要列出表中每个name字段值对应的最大日期怎么办?
    假如上表中
    我要得到:
    date值为2003-05-01的aa这条记录和date值为2003-05-02的bb记录多谢多谢
      

  4.   

    select * from table where date=(select max(date) from table) group by name