sql语句写法(应该好写)

蔡问:
表1记有入库纪录:名字,数量。(名字可以重复)
表2记有名字,总量(名字不可以重复)
问:
怎样把表2中的总量按照名字分别修改为表1中数量的和
[99 byte] By [coo-25] at [2008-2-13]
# 1
delete from tb2
insert tb2 select 名字,sum(数量) from tb1 group by 名字
inalover-奇遇 at 2007-10-26 > top of Msdn China Tech,MS-SQL Server,应用实例...
# 2
select 名字,sum(数量) as 总量 into 表2
from 表1
z_hongbao at 2007-10-26 > top of Msdn China Tech,MS-SQL Server,应用实例...
# 3
update 表2 a set a.总量 = (select sum(数量) from 表1 b where a.名字 = b.名字);
IronPromises-铁诺 at 2007-10-26 > top of Msdn China Tech,MS-SQL Server,应用实例...
# 4
select 名字,sum(数量) as 总量 into 表2
from 表1
group by 名字
z_hongbao at 2007-10-26 > top of Msdn China Tech,MS-SQL Server,应用实例...