selectcount(b.user_initial_ccid)from dwd.dwd_ccid_register_a a
leftjoin audience_data_service.sys_user_all b
on((b.user_id=a.union_id_md5 and b.user_type_id=15)or(b.user_id=a.mobile_md5 and b.user_type_id=16)or(b.user_id=a.email_md5 and b.user_type_id=11)or(b.user_id=a.open_id_md5 and b.user_type_id=14)or(b.user_id=a.alipay_id_md5 and b.user_type_id=18)or(b.user_id=a.wechat_id_md5 and b.user_type_id=13)or(b.user_id=a.ip_md5 and b.user_type_id=12))and b.dt='current';
优化后
droptableifexists tmp.tmp_count1;createtable tmp.tmp_count1 asselect b.ccid,a.*from dwd.dwd_ccid_register_a a
leftjoin audience_data_service.sys_user_ccid_all b
oncasewhen a.mobile_md5 isnotnullthen a.mobile_md5
when a.union_id_md5 isnotnullthen a.union_id_md5
when a.open_id_md5 isnotnullthen a.open_id_md5
when a.email_md5 isnotnullthen a.email_md5
when a.alipay_id_md5 isnotnullthen a.alipay_id_md5 end= b.user_id
andcasewhen a.mobile_md5 isnotnullthen16when a.union_id_md5 isnotnullthen15when a.open_id_md5 isnotnullthen14when a.email_md5 isnotnullthen11when a.alipay_id_md5 isnotnullthen18end= b.user_type_id;