select name,sum(money) as money
from 表
group by name

解决方案 »

  1.   

    select name,sum(money) as money
    from table
    group by name
      

  2.   

    select name,[money]=sum([money]) from 表 group by name
      

  3.   

    --下面是测试
    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 行)
    --*/
      

  4.   

    select name,sum(money) as money from table
    group by name
      

  5.   

    select name,sum(money) as money
    from tablename
    group by name