-- 没使用前
SELECT count(A.用户ID) 首次, count(B.用户ID) 再次, CONCAT(count(B.用户ID)/count(A.用户ID)*100,'%') 再购率 FROM
(SELECT DISTINCT 用户ID FROM 用户购买20110901) A
LEFT JOIN
(SELECT DISTINCT 用户ID FROM 用户购买20110902) B
ON A.用户ID = B.用户ID;
-- 使用后
SELECT count(A.用户ID) 首次, count(B.用户ID) 再次, CONCAT(FORMAT(count(B.用户ID)/count(A.用户ID)*100,1),'%') 再购率 FROM
(SELECT DISTINCT 用户ID FROM 用户购买20110901) A
LEFT JOIN
(SELECT DISTINCT 用户ID FROM 用户购买20110902) B
ON A.用户ID = B.用户ID;
网友评论