if OBJECT_ID('tempdb..##t2') is not null drop table ##t2;create table ##t2( a int, b int, c datetime, d varchar(100), e varchar(100), f int, g int);select * from ##t2; update ##t2set f = t3.f,g = t3.gFROM ##t2,(select f.NID,count(s.NID) skuCount,sum(