1、select a 元素,count(*) 个数 from
(
select a a from shiyan
union all
select b a from shiyan
union all
select c a from shiyan
union all
select d a from shiyan
union all
select e a from shiyan
) B
(
select a a from shiyan
union all
select b a from shiyan
union all
select c a from shiyan
union all
select d a from shiyan
union all
select e a from shiyan
) B
insert shiyan select 1,1,3,4,6,NULL
union all select 2,2,3,4,NULL,NULL
union all select 3,1,2,3,NULL,NULL
union all select 4,2,6,NULL,NULL,NULL
union all select 5,2,3,4,5,NULL
union all select 6,2,3,5,NULL,NULL
union all select 7,1,2,3,4,6
union all select 8,1,3,4,5,6
union all select 9,1,NULL,NULL,NULL,NULLselect a 元素,count(*) 个数 from
(
select a a from shiyan
union all
select b a from shiyan
union all
select c a from shiyan
union all
select d a from shiyan
union all
select e a from shiyan
) B where a is not null group by adrop table shiyan
select * into 表2 from 表1
alter table 表2 add item3 varchar
go