日期:2014-05-18 浏览次数:20667 次
if object_id('[tb]') is not null drop table [tb] go create table [tb]([name] varchar(2),[num] int) insert [tb] select 'qq',1 union all select 'qq',2 union all select 'mm',3 union all select 'aa',2 union all select 'qq',1 union all select 'aa',1 union all select 'mm',2 go select name,sum(num) as num from tb group by name /** name num ---- ----------- aa 3 mm 5 qq 4 (3 行受影响) **/