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
对不起,刚才错了。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
又错了!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
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
没有主键可用: 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
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
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
这个应该是对的吧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
from t a inner join t b on a.a=b.a
from t a ,(select a,d=max(b),e=max(c)
from t group by a )b
where a.a=b.a
from t a ,(select a,d=max(b),e=max(c)
from t group by a )b
where a.a=b.a
from t a left join (select a,d=max(b),e=max(c)
from t group by a )b
on a.a=b.a
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
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
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
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