日期:2014-05-18 浏览次数:20556 次
update a set field30=b.field30 from tb a, (select groupcode,max([Field30]) from tb group by groupcode)b where a.groupcode=b.groupcode
------解决方案--------------------
update tb set Field30 = (select max(Field30) from tb where groupcode = t.groupcode) from tb t
------解决方案--------------------
create table tb( srn varchar(50), groupcode varchar(50), field30 varchar(50) ) go Insert into tb(srn,groupcode,field30) values('h30511','*20111207000079*','LK169849491CN') Insert into tb(srn,groupcode) values('h30510','*20111207000079*') Insert into tb(srn,groupcode) values('u70377','*20111207000116*') Insert into tb(srn,groupcode) values('u70374','*20111207000116*') Insert into tb(srn,groupcode,field30) values('u70375','*20111207000116*','LK168318165CN') Insert into tb(srn,groupcode) values('u70376','*20111207000116*') go update tb set field30=(select top 1 field30 from tb where groupcode=a.groupcode and field30 is not null) from tb a go select * from tb go drop table tb
------解决方案--------------------
错了=。=
update
a
set
field30=b.field30
from
tb a,
(select groupcode,max([Field30] Field30 ) from tb group by groupcode)b
where
a.groupcode=b.groupcode