阅读列表 :
一、 更新跟进人姓名
二、 创建客户表的对比表
三、 查询重复客户(总)
四、 查询重复客户(五人)
一、 更新跟进人姓名
UPDATE g_ec_customer SET follow_user_name = ( CASE follow_user_id WHEN '6582553' THEN '廖梓秀' WHEN '6582564' THEN '刘琪燕' WHEN '6624924' THEN '陈欣蕾' WHEN '6624972' THEN '袁良' WHEN '7166053' THEN '刘虎' WHEN '7166071' THEN '林龙飞' WHEN '7166183' THEN '陈利国' WHEN '7240909' THEN '方垒' WHEN '7240941' THEN '汪开胜' WHEN '7360237' THEN '李娜' WHEN '7360262' THEN '程会子' END );
二、 创建客户表的对比表
CREATE TABLE g_ec_dist AS ( SELECT t.follow_user_name, t.crm_id, t.`name`, t.mobile, t.create_time FROM g_ec_customer t WHERE t.create_time <= '2018-04-30 23:59:59' AND t.follow_user_name != '' AND t.follow_user_name IS NOT NULL ORDER BY t.follow_user_name, t.create_time );
三、 查询重复客户(总)
SELECT t.follow_user_name, t.crm_id, t.`name`, t.mobile, t.create_time, t2.follow_user_name, t2.crm_id, t2.`name`, t2.mobile, t2.create_time FROM g_ec_customer t, g_ec_dist t2 WHERE t.`name` = t2.mobile AND t.create_time != t2.create_time AND t.create_time <= '2018-04-30 23:59:59' AND t.follow_user_name != '' AND t.follow_user_name IS NOT NULL AND t.follow_user_name != t2.follow_user_name ORDER BY t.follow_user_name,t.create_time;
四、 查询重复客户(五人)
SELECT t.follow_user_name, t.crm_id, t.`name`, t.mobile, t.create_time, t2.follow_user_name, t2.crm_id, t2.`name`, t2.mobile, t2.create_time FROM g_ec_customer t, g_ec_dist t2 WHERE t.`name` = t2.mobile AND t.create_time != t2.create_time AND t.create_time <= '2018-04-30 23:59:59' AND t.follow_user_name != '' AND t.follow_user_name IS NOT NULL AND t.follow_user_name != t2.follow_user_name AND (t.follow_user_name IN ('方磊','汪开胜','陈立国','刘虎','林龙飞') OR t2.follow_user_name IN ('方磊','汪开胜','陈立国','刘虎','林龙飞')) ORDER BY t.follow_user_name,t.create_time;