declare @t table(c varchar(4)) insert into @t select 'a' insert into @t select 'b' insert into @t select 'b' insert into @t select 'c' insert into @t select 'c' insert into @t select 'c' insert into @t select 'd' insert into @t select 'd' insert into @t select 'd' insert into @t select 'd'select top 10 c,count(*) 出现次数 from @t group by c order by 出现次数 desc
select 列,出现次数=count(1) from 表 group by 列
---------- select 列,出现次数=count(1) from 表 group by 列 order by 出现次数 desc
select colname,count(*) from table group by colname
select 列,出现次数=count(1) from 表 group by 列 order by 出现次数 desc
列 出现次数
c 3
b 2
a 1
insert into @t select 'a'
insert into @t select 'b'
insert into @t select 'b'
insert into @t select 'c'
insert into @t select 'c'
insert into @t select 'c'
insert into @t select 'd'
insert into @t select 'd'
insert into @t select 'd'
insert into @t select 'd'select top 10 c,count(*) 出现次数 from @t group by c order by 出现次数 desc
----------
select 列,出现次数=count(1) from 表 group by 列 order by 出现次数 desc
group by 列
order by 出现次数 desc