表1 结构 a b c 均为主键 表2 结构 a b 均为主键
a b c a b d
1 2 3 1 2 5
1 2 4
1 2 6 以a,b为key 连接,像得到这样的结果,该如何做,请赐教:
a b c 5
1 2 3,4,6 6
select tt.a,tt.b,B.d,substr(max(sys_connect_by_path(tt.c, ', ')),2)
from (select A.a,A.b,A.c,1+row_number()over(partition by A,a,A.b order by A.a,A.b)seq1,
row_number()over(partition by A,a,A.b order by A.a,A.b) seq2 from A)tt,B
where tt.a=B.a
and tt.b=B.b
start with tt.seq2=1
connect by tt.seq2=prior tt.seq1
group by tt.a,tt.b,B.d
昨天我遇到了个难题,Angel_ling帮我解答了,今天测试完全正确,但是对于substr(max(sys_connect_by_path(tt.c, ', ')),2) 不明白,特别是 “2”这个参数,有什么说法吗??我用3 ,4 测试也都正确?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货