写个SQL
表AA
结构如下:
name   dt
  A    2001/01/02
  A    2002/01/02
  A    2003/01/02
  B    2001/01/02
  B    2002/01/02
要求找出
  A    2003/01/02
  B    2002/01/02
(日期最大的所有记录) 

解决方案 »

  1.   

    select * from AA where td = (select max(td) from AA)
      

  2.   

    select top 1 name,max(dt) from AA
      

  3.   

    select name,max(dt) from AA group by name
      

  4.   

    我还想问一下,如果后面还有一个字段呢?

       name      dt            age
       A        2001/01/02      65
       A        2002/01/02      45
       A        2003/01/02      44
       B        2001/01/02       2
       B        2002/01/02       5
    要求找出  
       A        2003/01/02       44
       B        2002/01/02       5
    (日期最大的所有记录
      

  5.   

    请copico(路北)
    看一下。呵呵~~~
      

  6.   

    select name,max(dt),age from AA group by name,age
      

  7.   

    多少列都行:select * from table A where not exists(select 1 from table where name=A.name and dt>A.dt)