22,209
社区成员
发帖
与我相关
我的任务
分享
--给GROUP BY后的字段和sum的字段加索引
create index idx_01 on 表名(列一,列二,列三...,sum的字段)
if object_id('tb') is not null
drop table tb
go
create table tb(a int,b int,c int,num int)
create clustered index id_index on tb(a,b,c)
select a,b,c ,sum(num) from tb
group by a,b,c