求教sql
有个表tab
AA BB
1 a
2 b
3 c
4 d
查出结果是ab ac ad bc bd cd
------解决方案--------------------如果不考虑效率问题
with t1 as
(
select 1 c1,'a' c2 from dual
union all
select 2 c1,'b' c2 from dual
union all
select 3 c1,'c' c2 from dual
union all
select 4 c1,'d' c2 from dual
)
select a.c2
------解决方案--------------------b.c2 c1
from t1 a full join t1 b on a.c2 < b.c2
where length(a.c2
------解决方案--------------------b.c2) > length(a.c2)
c1
------------------
1 ab
2 ac
3 ad
4 bc
5 bd
6 cd