表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    d
  1 2   3,4,6 6

解决方案 »

  1.   

     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试试 可不可以,我测试是成功的