select * from tableA 
where atime in 
            (select name,time,max(Atime) 
             from tableA
             group by name,time)

解决方案 »

  1.   

    select *
    from tablea a
    where not exists(select * from tablea where a.name = name and a.time = time and a.Atime < atime)
      

  2.   

    create table tr (id int, name varchar(8),time datetime,atime datetime)
    insert into tr select '1','ab','2004/12/20','2004/12/21'
    union all 
    select '2','ab','2004/12/20','2004/12/22select *
    from tr a
    where not exists(select * from tr where a.name = name and a.time = time and a.Atime < atime)
      

  3.   

    select * from tableA  as a
    where Atime =(select max(Atime) from tableA where a.name = name and a.time = time)
      

  4.   


    SELECT a.* FROM tableA a WHERE a.Atime IN
    (
    SELECT MAX(b.Atime) FROM tableA b GROUP BY b.name,b.time HAVING b.name = a.name AND b.time = a.time
    )
    ORDER BY a.ID