改为
id num id num
102 1 102 2
102 3 102 4
102 5 102 6
102 7 102 8
4 个解决方案
#1
你给的示例明显是4行,不是一行啊
#2
虽然我不知道怎么改,但是我明白楼主的意思、
人家那是4“列”。。。不是4行
#3
如果不需计算,那用lead函数很方便
如果需并成6列,则在select后面增加id3,num3,并将mod(rn,2)=1改成mod(rn,3)=1即可
select id1,num1,id2,num2 from
(select id id1,num num1,lead(id,1,'') over (order by num) id2,lead(num,1,0) over(order by num) num2,rownum rn from YourTable)
where mod(rn,2)=1
如果需并成6列,则在select后面增加id3,num3,并将mod(rn,2)=1改成mod(rn,3)=1即可
#4
已解决 多谢
select a.flight_airline_direction_seq,
b.flight_airline_direction_seq,
a.flight_airline_id
from (select flight_airline_id, flight_airline_direction_seq
from naip2015_04.flight_airline_point0 t
where FLIGHT_AIRLINE_ID = 102
and mod(FLIGHT_AIRLINE_DIRECTION_SEQ, 2) = 1) a,
(select flight_airline_id, flight_airline_direction_seq
from naip2015_04.flight_airline_point0 d
where FLIGHT_AIRLINE_ID = 102
and mod(FLIGHT_AIRLINE_DIRECTION_SEQ, 2) = 0) b
where a.flight_airline_id = b.flight_airline_id
and a.flight_airline_direction_seq + 1 = b.flight_airline_direction_seq
select a.flight_airline_direction_seq,
b.flight_airline_direction_seq,
a.flight_airline_id
from (select flight_airline_id, flight_airline_direction_seq
from naip2015_04.flight_airline_point0 t
where FLIGHT_AIRLINE_ID = 102
and mod(FLIGHT_AIRLINE_DIRECTION_SEQ, 2) = 1) a,
(select flight_airline_id, flight_airline_direction_seq
from naip2015_04.flight_airline_point0 d
where FLIGHT_AIRLINE_ID = 102
and mod(FLIGHT_AIRLINE_DIRECTION_SEQ, 2) = 0) b
where a.flight_airline_id = b.flight_airline_id
and a.flight_airline_direction_seq + 1 = b.flight_airline_direction_seq
#1
你给的示例明显是4行,不是一行啊
#2
虽然我不知道怎么改,但是我明白楼主的意思、
人家那是4“列”。。。不是4行
#3
如果不需计算,那用lead函数很方便
如果需并成6列,则在select后面增加id3,num3,并将mod(rn,2)=1改成mod(rn,3)=1即可
select id1,num1,id2,num2 from
(select id id1,num num1,lead(id,1,'') over (order by num) id2,lead(num,1,0) over(order by num) num2,rownum rn from YourTable)
where mod(rn,2)=1
如果需并成6列,则在select后面增加id3,num3,并将mod(rn,2)=1改成mod(rn,3)=1即可
#4
已解决 多谢
select a.flight_airline_direction_seq,
b.flight_airline_direction_seq,
a.flight_airline_id
from (select flight_airline_id, flight_airline_direction_seq
from naip2015_04.flight_airline_point0 t
where FLIGHT_AIRLINE_ID = 102
and mod(FLIGHT_AIRLINE_DIRECTION_SEQ, 2) = 1) a,
(select flight_airline_id, flight_airline_direction_seq
from naip2015_04.flight_airline_point0 d
where FLIGHT_AIRLINE_ID = 102
and mod(FLIGHT_AIRLINE_DIRECTION_SEQ, 2) = 0) b
where a.flight_airline_id = b.flight_airline_id
and a.flight_airline_direction_seq + 1 = b.flight_airline_direction_seq
select a.flight_airline_direction_seq,
b.flight_airline_direction_seq,
a.flight_airline_id
from (select flight_airline_id, flight_airline_direction_seq
from naip2015_04.flight_airline_point0 t
where FLIGHT_AIRLINE_ID = 102
and mod(FLIGHT_AIRLINE_DIRECTION_SEQ, 2) = 1) a,
(select flight_airline_id, flight_airline_direction_seq
from naip2015_04.flight_airline_point0 d
where FLIGHT_AIRLINE_ID = 102
and mod(FLIGHT_AIRLINE_DIRECTION_SEQ, 2) = 0) b
where a.flight_airline_id = b.flight_airline_id
and a.flight_airline_direction_seq + 1 = b.flight_airline_direction_seq