select name,sum(money) as money from table group by name
select name,[money]=sum([money]) from 表 group by name
--下面是测试 declare @表 table(Name varchar(10),[money] money) insert into @表 select 'David',123.78 union all select 'David',22.32 union all select 'David',200.20 union all select 'Peter',100 union all select 'Peter',500--查询 select name,[money]=sum([money]) from @表 group by name/*--测试结果name money ---------- --------------------- David 346.3000 Peter 600.0000(所影响的行数为 2 行) --*/
select name,sum(money) as money from table group by name
select name,sum(money) as money from tablename group by name
from table
group by name
declare @表 table(Name varchar(10),[money] money)
insert into @表
select 'David',123.78
union all select 'David',22.32
union all select 'David',200.20
union all select 'Peter',100
union all select 'Peter',500--查询
select name,[money]=sum([money]) from @表 group by name/*--测试结果name money
---------- ---------------------
David 346.3000
Peter 600.0000(所影响的行数为 2 行)
--*/
group by name
from tablename
group by name