with result as(
select t.str from(
select '1' str
union all
select '2' str
union all
select '3' str
union all
select '4' str
union all
select '5' str
union all
select '6' str
union all
select '7' str
) t
cross apply
(select t2.str from(
select '1' str
union all
select '2' str
union all
select '3' str
union all
select '4' str
) t2
where t.str = t2.str) t3)
select * from result;
go
with result as(
select t.str from(
select '1' str
union all
select '2' str
union all
select '3' str
union all
select '4' str
union all
select '5' str
union all
select '6' str
union all
select '7' str
) t
outer apply
(select t2.str from(
select '1' str
union all
select '2' str
union all
select '3' str
union all
select '4' str
) t2
where t.str = t2.str) t3)
select * from result;
go
select t.str from(
select '1' str
union all
select '2' str
union all
select '3' str
union all
select '4' str
union all
select '5' str
union all
select '6' str
union all
select '7' str
) t
cross apply
(select t2.str from(
select '1' str
union all
select '2' str
union all
select '3' str
union all
select '4' str
) t2
where t.str = t2.str) t3;
go