select * from 表A a
inner join
(select stusent_id, max(time) as max_time  from A  GROUP BY stusent_id) b
on a.stusent_id=b.stusent_id

解决方案 »

  1.   

    select *
    from 表A a
    where not exists(select 1 from 表A where stusent_id=a.stusent_id and time>a.time)
      

  2.   

    select * from a where id in(select max(id) from a group by stusent_id )
      

  3.   

    select * from a where time in(select max(time) from a group by stusent_id)
      

  4.   

    select * from a where time in(select max(time) from a group by stusent_id)
      

  5.   

    SELECT * FROM Test051114  a right outer join
              (SELECT stusent_id, MAX([time]) AS Expr2
             FROM Test051114
             GROUP BY stusent_id) b on a.stusent_id=b.stusent_id and a.[time]=b.Expr2
      

  6.   

    create table 表A 
    (
    id int,
    stusent_id  varchar(30),
    time varchar(30),
    dep varchar(30)
    )insert into 表A
    select 1,'001','20041110','计算机' union all
    select 2,'001','20050910','工商管理学' union all
    select 3,'002','20031010','计算机' union all
    select 4,'002','20051010','自动化'select 表A.* from 表A,
    (select stusent_id,max(time) as time from 表A group by stusent_id) T2
    where 表A.stusent_id=T2.stusent_id
    and 表A.time=T2.time
    order by id
      

  7.   

    select * from 表A a
    where exists (select 1 from 表A  where a.stusent_id=stusent_id group by stusent_id having max(time)=a.time)