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