62,046
社区成员
发帖
与我相关
我的任务
分享
declare @t table(
name varchar(10)
)
insert into @t select '1'
insert into @t select '2'
insert into @t select '3'
insert into @t select '4'
select * from @t
select name from @t group by name
--错误的用别名分组
--select name n from @t group by n
--使用别名分组
select * from (select name n from @t) t group by n
select col1,col2,col3 from (select col1, (select ... ...) as col2, (select .. ... )as col3) group by col1,col2,col3