可以需要编写存储函数
f_add(iv_id varchar2)
用游标把字段table2中的id2=iv_id的n_code列值加起来select id1,m_name,f_add(id1) from table1

解决方案 »

  1.   

    select id1 m_Name  n_Code  
    a01  aaaa   nPPP1,nPPP2  
    a02  bbbb   nQQQ1 from TABLE1,TABLE2
      

  2.   

    select id,m_name,max(sys_connect_by_path(n_code,',')) as code from (
    select id,m_name,n_code,rn,
    lag(rn) over(partition by id order by rn) as rn1 from (
    select id,m_name,n_code,m_date,
    row_number() over(partition by id order by n_code) as rn
    from (
    select t1.id,t1.m_name,t1.m_date,t2.n_code from t1,t2 where t1.id=t2.id)))
    start with rn1 is null
    connect by prior rn = rn1
    group by id,m_name