try
create table #t (a int,b int,c int,d int)insert into #t select 1,2,3,4
insert into #t select 1,2,3,4
insert into #t select 0,1,4,3 
 select count(*) 次数,a from(
select a from #t
union all
select b from #t
union all
select c from #t
union all
select d from #t) as t 
group by a