if exists (select * from sysobjects where object_id('a ')=id and objectproperty(id,'isUserTable')=1)
drop table a
go
create table a (a varchar(10) null,b int null)
go
insert into a
select '李三',1 union all
select '李三',2 union all
select '李三',3 union all
select '李三',3 union all
select '李三',4 union all
select '張三',2 union all
select '張三',3 union all
select '王三',3 union all
select '鄧三',4
go
select * from a
/*
a b
李三 1
李三 2
李三 3
李三 3
李三 4
張三 2
張三 3
王三 3
鄧三 4
*/
select a,sum(b) c from a group by a
/*
a c
王三 3
李三 13
張三 5
鄧三 4
*/