--3楼应该是OK的,使用reverse函数排序 SELECT * FROM (SELECT a FROM tt UNION ALL SELECT b FROM tt) ORDER BY REVERSE(a);
with temp as( select 'A1' A,'B1' B from dual union all select 'A2' A,'B2' B from dual union all select 'A3' A,'B3' B from dual ) select * from( select A from temp union all select B from temp ) order by reverse(a);
SQL> select a from T union all select b from T;A ---- A1 A2 A3 B1 B2 B3123的排序不是楼主想要的。to--5楼
这里只是测试数据,感觉不应该用reverse with temp as( select 'A1' A,'B1' B from dual union all select 'A2' A,'B2' B from dual union all select 'A3' A,'B3' B from dual ) select col from( select A col,rownum rn from temp union all select B col,rownum+0.5 rn from temp ) order by rn;
轻微变态点 要是排列成这样子呢 B1 A1 B2 A2 B3 A3
如果是 字段 A B A3 B3 A2 B2 A1 B1 reverse 不能达到要求。还是支持9楼这种变通的方法
select 1 seq, A from T union select 2 seq, B from T order by 2,1;
union
select B from T
union all
select B from T
SELECT *
FROM (SELECT a
FROM tt
UNION ALL
SELECT b FROM tt)
ORDER BY REVERSE(a);
with temp as(
select 'A1' A,'B1' B from dual
union all
select 'A2' A,'B2' B from dual
union all
select 'A3' A,'B3' B from dual
)
select * from(
select A from temp
union all
select B from temp
) order by reverse(a);
----
A1
A2
A3
B1
B2
B3123的排序不是楼主想要的。to--5楼
with temp as(
select 'A1' A,'B1' B from dual
union all
select 'A2' A,'B2' B from dual
union all
select 'A3' A,'B3' B from dual
)
select col from(
select A col,rownum rn from temp
union all
select B col,rownum+0.5 rn from temp
) order by rn;
要是排列成这样子呢
B1 A1 B2 A2 B3 A3
如果是
字段
A B
A3 B3
A2 B2
A1 B1
reverse 不能达到要求。还是支持9楼这种变通的方法
union
select 2 seq, B from T
order by 2,1;