zoukankan      html  css  js  c++  java
  • MK新老顾问自主拜访率

     use Omniture
     
     select VLR.YearMonth
     ,VLR.VisitorID
     ,VLR.ConsultantID
     ,VLR.Visits
     ,CL.LevelID
     ,CL.[Status]
     ,IfNew = case when 
     (VLR.YearMonth=startmonth) then '1'
     else '0' end
     into #VisitsLogin
     from VisitsLoginRecord VLR
      inner join (select *,CONVERT(varchar(6),StartDate,112) as startmonth 
     from ConsultantInfo) vstime on VLR.ConsultantID=vstime.ConsultantID
     inner join ConsultantLevel CL on VLR.ConsultantID=CL.ConsultantID and VLR.YearMonth=CL.YearMonth
    
    select COUNT(*) from #VisitsLogin
    
    
    --ALL访问记录与等级记录关联
    select V.YearMonth
    ,V.VisitorID
    ,V.ConsultantID
    ,v.Visits
    ,V.ifnew
    ,CL.LevelID
    ,CL.[Status]
    into #temp1
    from #VisitsLogin V
    inner join dbo.[ConsultantLevel] CL
    on V.ConsultantID=CL.ConsultantID
    and V.YearMonth=CL.YearMonth
    
    --New访问记录与等级记录关联
    select V.YearMonth
    ,V.VisitorID
    ,V.ConsultantID
    ,v.Visits
    ,V.ifnew
    ,NCL.LevelID
    ,NCL.[Status]
    into #tempnew1
    from #VisitsLogin V
    inner join dbo.[ConsultantLevel] NCL
    on V.ConsultantID=NCL.ConsultantID
    and V.YearMonth=NCL.YearMonth
    and V.ifnew=1
    
    --Old访问记录与等级记录关联
    select V.YearMonth
    ,V.VisitorID
    ,V.ConsultantID
    ,v.Visits
    ,V.ifnew
    ,OCL.LevelID
    ,OCL.[Status]
    into #tempold1
    from #VisitsLogin V
    inner join dbo.[ConsultantLevel] OCL
    on V.ConsultantID=OCL.ConsultantID
    and V.YearMonth=OCL.YearMonth
    and V.ifnew<>1
    
    
    --ALL访问顾问人数
    select YearMonth
    ,COUNT(distinct ConsultantID) as ConNum
    from #temp1
    group by YearMonth
    
    --New访问顾问人数
    select YearMonth
    ,COUNT(distinct ConsultantID) as ConNum
    from #tempnew1
    group by YearMonth
    
    --Old访问顾问人数
    select YearMonth
    ,COUNT(distinct ConsultantID) as ConNum
    from #tempold1
    group by YearMonth
    
    
    --All独立设备访问顾问数
    select * 
    into #temprank1
    from (
    select YearMonth
    ,VisitorID
    ,ConsultantID
    ,ifnew
    ,rank() over (partition by VisitorID order by CONVERT(int,LevelID) desc ) as Ranknom
     from #temp1) as st
     where st.Ranknom=1
     
     select YearMonth
     ,COUNT(distinct ConsultantID)
     from #temprank1
     group by YearMonth
    
    
    --New独立设备访问顾问数
    select * 
    into #tempnewrank1
    from (
    select YearMonth
    ,VisitorID
    ,ConsultantID
    ,ifnew
    ,RANK() over (partition by VisitorID order by CONVERT(int,LevelID) desc ) as RankNum
     from #temp1
     ) as st
     where st.RankNum=1
     and st.ifnew=1
     
     select YearMonth
     ,COUNT(distinct ConsultantID)
     from #tempnewrank1
     group by YearMonth
    
    
    --Old独立设备访问顾问数
    select * 
    into #tempoldrank1
    from (
    select YearMonth
    ,VisitorID
    ,ConsultantID
    ,ifnew
    ,rank() over (partition by VisitorID order by CONVERT(int,LevelID) desc ) as RankNum
     from #temp1
     ) as st
     where st.RankNum=1
     and st.ifnew<>1
     
    select YearMonth
     ,COUNT(distinct ConsultantID)
     from #tempoldrank1
     group by YearMonth
  • 相关阅读:
    eclipse中如何复制用点分隔的全类名
    win7 64下暗黑世界V1.1 服务器端及客户端的安装及运行 成功
    Firefly Http通信简单介绍
    win7 不能启动 memcached 总是反回failde to start service
    win7 安装 memcached
    memcached完全剖析–1. memcached的基础
    【Firefly API 新版文档】Package dbentrust
    《暗黑世界GM管理后台系统》部署+功能说明
    [官方教程] 暗黑世界 客户端 配置文档
    MAC下《暗黑世界》客户端版本编译说明!!
  • 原文地址:https://www.cnblogs.com/monkeyfather/p/3867887.html
Copyright © 2011-2022 走看看