16
12/11
SQL分组查询
情景一: 表中数据 name score aaa 11 aaa 19 bbb 12 bbb 18 ccc 19 ddd 21 期望查询结果如下 name score aaa 30 bbb 30 ccc 19 ddd 21 复制代码代码如下: ---检查表是否存在 if exists(select * from sysobjects where name='testSum') drop table testSum go ---创建表 create table testSum ( tid int primary key identity(1,1), tname varchar(30) null, tscor int null ) go insert into testSum (tname,tscor) select 'aaa',11 union all select 'aaa',19 union all select 'bbb',12 union all select 'bbb...