
谁能帮我看这段SQL语句:---for W02 ---script 1 alter table W02 add ID int identity(1,1); -----script
-----script2selectmin(ID)asIDinto#TEMPfromW01GroupbyGB011;updateW01setGB011=nullwhere...
-----script 2
select min(ID) as ID into #TEMP from W01 Group by GB011;
update W01
set GB011= null
where ID not in (select ID from #TEMP);
drop table #TEMP;
alter table W01 drop column ID; 展开
select min(ID) as ID into #TEMP from W01 Group by GB011;
update W01
set GB011= null
where ID not in (select ID from #TEMP);
drop table #TEMP;
alter table W01 drop column ID; 展开
1个回答
展开全部
--W01中每组GB011的最小ID放到表#TEMP中
select min(ID) as ID into #TEMP from W01 Group by GB011;
--修改W01,将W01中有但是#TEMP中没有的ID,GB011改为null
update W01
set GB011= null
where ID not in (select ID from #TEMP);
--删除表#TEMP
drop table #TEMP;
--删除列ID
alter table W01 drop column ID;
其实就是把每一组GB011中非最小ID的行GB011改为空
select min(ID) as ID into #TEMP from W01 Group by GB011;
--修改W01,将W01中有但是#TEMP中没有的ID,GB011改为null
update W01
set GB011= null
where ID not in (select ID from #TEMP);
--删除表#TEMP
drop table #TEMP;
--删除列ID
alter table W01 drop column ID;
其实就是把每一组GB011中非最小ID的行GB011改为空
追问
能具体指导下吗?我的QQ412676478
追答
。。。你还有什么问题吗?可以百度私信我,qq我不太用
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询