如何获得以下输出?
输入:
t1
-----------------
col1 col2
----------------
2 a
1 c
3 b
----------------
输出:
t1
-----------------
col1 col2
----------------
1 a
2 b
3 c
----------------
您可以尝试使用行号,例如:
SELECT row_number() OVER (ORDER BY a.col2) as col1, col2
FROM t1 a ORDER BY a.col2
select C1.col1, C2.col2
from
(select col1, row_number() over (order by col1) rn
from t1) C1
join
(select col2, row_number() over (order by col2) rn
from t1) C2
on C1.rn=C2.rn
order by C1.rn
尝试这个..
select col1,col2 from
(select col1,rownum rn from(select col1 from t1 order by col1)) a,
(select col2,rownum rn from(select col2 from t1 order by col2)) b
where a.rn=b.rn
我认为以下查询可能会对您有所帮助。
SELECT * FROM t1 ORDER BY col1 ;
请检查此链接以获取更多练习