select 标识,count(1) from table group by 标识 order by 标识
select count(*),标识 from tb group by 标识
--分组查询 select 标识,count(*) cnt from tb where 标识='语文' or 标识='数学' group by 标识
select count(*) from tb where 标识 like'语文%'
select '语文',count(*) from tb where charindex('语文',标识)>0
use dbx; godeclare @t table(标识 varchar(100)); insert into @t select '语文,数学,化学' union all select '数学,英语,物理' union all select '化学' union all select '英语,语文';select * from @t;declare @a table(id varchar(100)); insert into @a select '语文' union all select '数学' union all select '物理' union all select '化学' union all select '英语';select a.id,COUNT(1) as ct from @a a join @t b on b.标识 like '%'+a.id+'%' group by a.id
select 标识,count(*) cnt
from tb
group by 标识
--分组查询
select 标识,count(*) cnt
from tb where 标识='语文' or 标识='数学'
group by 标识
from tb
where charindex('语文',标识)>0
use dbx;
godeclare @t table(标识 varchar(100));
insert into @t select '语文,数学,化学' union all
select '数学,英语,物理' union all
select '化学' union all
select '英语,语文';select * from @t;declare @a table(id varchar(100));
insert into @a select '语文' union all select '数学' union all select '物理' union all select '化学' union all select '英语';select a.id,COUNT(1) as ct from @a a join @t b on b.标识 like '%'+a.id+'%'
group by a.id