日期:2014-05-17 浏览次数:20800 次
WITH t AS ( SELECT 'a' id FROM dual UNION ALL SELECT 'b' FROM dual UNION ALL SELECT 'c' FROM dual UNION ALL SELECT 'd' FROM dual ) SELECT t1.id||t2.id FROM t t1,t t2 WHERE t1.id<t2.id;
------解决方案--------------------
自连接做个迪卡尔集,再比较ASCII码大小。
with t as (
--NO NAME
select 1 as num, 'A' as name from dual
union all
select 2, 'B' from dual
union all
select 3, 'C' from dual
union all
select 4, 'D' from dual
)
select aname || bname from (
select a.num as anum,a.name as aname,b.num as bnum, b.name as bname from t a, t b)
where ascii(aname) < ascii(bname)
ANAME||BNAME
------------
AB
AC
AD
BC
BD
CD