美文网首页
营销渠道统计

营销渠道统计

作者: 俊学之道 | 来源:发表于2017-02-22 09:52 被阅读18次

    注册渠道信息统计

    SET @start_date=CURDATE()-1;
    SET @end_date=CURDATE();
    SELECT A.注册渠道,A.注册人数,B.绑卡人数,C.`投资人数`, C.`投资人数`/A.注册人数 AS 投资转化率 FROM
    (SELECT remark AS 注册渠道,COUNT(*) AS 注册人数 FROM b2015_gblc_user
    WHERE INTIME BETWEEN @start_date AND @end_date
    GROUP BY remark) A
    LEFT JOIN (SELECT remark AS 注册渠道,COUNT(*) AS 绑卡人数 FROM b2015_gblc_user
    WHERE INTIME BETWEEN @start_date AND @end_date
    AND RZSTATUS=2
    GROUP BY remark) B
    ON A.`注册渠道`=B.`注册渠道`
    LEFT JOIN (SELECT remark AS 注册渠道,COUNT(*) AS 投资人数 FROM
    (SELECT D.phone,D.INTIME,D.REMARK,MIN(E.intime) AS TZTIME,E.SUM AS First_investment,SUM(E.SUM) AS SUM_investment,
    CASE WHEN SUM>=100 THEN 3/*状态认证3表示已投资状态 */
    ELSE 4/*状态认证4表示未投资状态,也等于注册人数减去投资人数 */
    END AS RZSTATUS2
    FROM (SELECT * FROM b2015_gblc_user WHERE INTIME BETWEEN @start_date AND @end_date) AS D
    LEFT JOIN mairuorder AS E/*连接买入表,加入状态认证3表示已投资状态 */
    ON D.PHONE=E.uphone
    GROUP BY PHONE/*按phone分组目的是找出一个用户的一条最早买入记录*/
    ORDER BY INTIME) F
    WHERE RZSTATUS2=3
    GROUP BY remark) C
    ON A.`注册渠道`=C.`注册渠道`
    
    

    相关文章

      网友评论

          本文标题:营销渠道统计

          本文链接:https://www.haomeiwen.com/subject/xhbpwttx.html