--å建临æ¶è¡¨#temp
create table #temp -- select * from #temp drop table #temp
([name] varchar(36)
,num int)
--æå
¥æµè¯æ°æ®
insert into #temp
select 'A','2'
union all
select 'A','3'
union all
select 'B','4'
union all
select 'C','8'
union all
select 'A','6'
--æ§è¡æä½
select [name]
,avg(num) as [avg]
,max(num) as [max]
,min(num) as [min]
from #temp
group by [name]
order by [name]
--ç»æ
[name] [avg] [max] [min]
A 3 6 2
B 4 4 4
C 8 8 8
温馨提示:答案为网友推荐,仅供参考