declare @t table(id int,t_name varchar(10),f_name varchar(10))
insert into @t select 1,'植物','树'
union all select 2,'植物','花'
union all select 3,'植物','草'
union all select 4,'动物','猪'
union all select 5,'动物','狗'
union all select 6,'动物','牛'
union all select 7,'动物','羊'
union all select 8,'微生物','XXXX菌'
union all select 9,'微生物','AAAA菌'
select t_name+'('+cast(count(*) as varchar)+')' from @t group by t_name order by count(*) desc
--排下序
declare @t table(id int,t_name varchar(10),f_name varchar(10))
insert into @t select 1,'植物','树'
union all select 2,'植物','花'
union all select 3,'植物','草'
union all select 4,'动物','猪'
union all select 5,'动物','狗'
union all select 6,'动物','牛'
union all select 7,'动物','羊'
union all select 8,'微生物','XXXX菌'
union all select 9,'微生物','AAAA菌'
select t_name+'('+cast(count(*) as varchar)+')' from @t group by t_name