我需要通过SQL Oracle Query转置记录:
Table1:
Col1
1
2
3
4
5
AS
1 2
2 3
3 4
4 5
怎么可能?
答案 0 :(得分:0)
您可以使用lead()
:
select col1, col2
from (select col1, lead(col1) over (order by col1) as col2
from t
) t
where col2 is not null;
如果值实际上是没有间隙的连续数字,那么您可以使用join
。