题解 | 统计用户从访问到下单的转化率
WITH t1 AS ( SELECT date(visit_time) as date, count(DISTINCT user_id) as visit_cnt FROM visit_tb GROUP BY date(visit_time) ), t2 AS ( SELECT date(order_time) as date, count(DISTINCT user_id) as order_cnt FROM order_tb GROUP BY date(order_time) ) SELECT t1.date, CONCAT(round(order_cnt/visit_cnt*100,1),'%') cr FROM t1 LEFT JOIN t2 ON t1.date = t2.date