update t set t.d=r.d,t.e=r.e
from t Left join
  (select a,max(b) as d,max(c) as e
   from t group by a) as r
 on t.a=r.a

解决方案 »

  1.   

    select a.a,a.b,a.c,d=a.b,e=a.c 
    from t a inner join t b on a.a=b.a
      

  2.   

    对不起,刚才错了。select a.a,a.b,a.c,d=a.b,e=a.c 
    from t a ,(select a,d=max(b),e=max(c)
       from t group by a )b 
    where a.a=b.a
      

  3.   

    又错了!select a.a,a.b,a.c,b.d,b.e
    from t a ,(select a,d=max(b),e=max(c)
       from t group by a )b 
    where a.a=b.a
      

  4.   

    select a.*,b.d,b.e
    from t a left join (select a,d=max(b),e=max(c)
       from t group by a )b 
    on a.a=b.a
      

  5.   

    没有主键可用:
    select F=identity(int,1,1),* into #t from t
    select a,b,c into #t2 from #t
    where F in(select min(F) from #t group by a)
    drop table #t
    update  t set t.d=#t2.d,t.e=#t2.e
    from t,#t2
    where t.a=#t2.a
    drop table #t2
      

  6.   

    select F=identity(int,1,1),* into #t from t
    select a,b,c into #t2 from #t
    where F in(select min(F) from #t group by a)
    update  t set t.d=#t2.d,t.e=#t2.e
    from t,#t2
    where t.a=#t2.a
    drop table #t2,#t
      

  7.   

    update t set t.d=r.d,t.e=r.e
    from t Left join
      (select a,max(b) as d,max(c) as e
       from t group by a) as r
     on t.a=r.a
      

  8.   

    这个应该是对的吧select F=identity(int,1,1),* into #t from t
    select a,b,c into #t2 from #t
    where F in(select min(F) from #t group by a)
    update  t set t.d=#t2.b,t.e=#t2.c
    from t,#t2
    where t.a=#t2.a
    drop table #t2,#t