insert into tmp_linshi_type (prod_type,acc_nbr,shouligonghao,shouligou,lanzhuangrenjigou,subs_date,lanzhuanggonghao,qudaoxiaolei,jieruhaozhuangtai,
threeM,fourM,fiveM,acc_nbr_gui,serv_type_gui,del_gui,shouli_date_gong,qudaofuwu_gong,acc_nbr_yue,del_yue,gongdanlaiyuan_yue,acc_nbr_yue_jd,del_yue_jd,gongdanlaiyuan_yue_jd)
select distinct a.prod_type,a.acc_nbr,a.shouligonghao,a.shouligou,a.lanzhuangrenjigou,a.subs_date,a.lanzhuanggonghao,a.qudaoxiaolei,a.jieruhaozhuangtai,
a.threeM,a.fourM,a.fiveM,b.SUBS_NBR || ',',b.serv_type,b.ANSWER,c.act_date,c.CHANNEL_SERV,d.SUBS_NBR || ',',d.SERV_TYPE,d.ACT_REMARK,e.SUBS_NBR || ',',e.SERV_TYPE,e.TS_STATUS
from tmp_linshi_itv a
left join
(
select CUST_PHONE,SUBS_NBR,serv_type,ANSWER from RPT_ALL_SUBS_FILE_LIST_2018
union all
select CUST_PHONE,SUBS_NBR,serv_type,ANSWER from RPT_ALL_SUBS_FILE_LIST_201712
) b on a.acc_nbr = b.CUST_PHONE
left join RPT_GONGXIN c on a.acc_nbr = c.sg_nbr and c.month_id >= '201706'
left join RPT_provin_YJ d on a.acc_nbr = d.CUST_NBR and d.month_id >= '201706'
left join RPT_JITUAN_YJ e on a.acc_nbr = e.SHGAO_NBR and e.month_id >= '201706';
如标题,求去重方法或思路,谢谢!!!