zoukankan      html  css  js  c++  java
  • SQL Server 订单分析

    select  distinct PurchasedByContactID as PurchasedByContactID into #SP
    from BASKET.. BaseOrderTracker(nolock )
    where OrderDate> '2014-2-1' and OrderDate< '2014-3-1' and OrderTypeID =15 and      OESourceID= 2
    and StageID= 10400
    
    select  distinct PurchasedByContactID as PurchasedByContactID into #P
    from BASKET.. BaseOrderTracker(nolock )
    where OrderDate> '2014-2-1' and OrderDate< '2014-3-1'  and OrderTypeID= 15 and  OESourceID= 2
    
    --流失的人
    select a.* into #NSP from #P( nolock)        as a
    where not exists(select top 1 1 from #SP as b where a.PurchasedByContactID= b.PurchasedByContactID )
    
    --流失人的详细信息
    select c. StartDate as StartDate ,c. ConsultantLevelID as Levelcode ,
    i.DirectSellerID as DirectSellerID, #NSP.PurchasedByContactID as contactId
    into #SNPD
    from CONTACTS.. consultants c(nolock )  inner join #NSP ( nolock )
    on #NSP. PurchasedByContactID=c .ContactID  inner join CONTACTS..InternationalConsultants i( nolock)
    on c. ContactID=i .ContactID
    
    
    --流失的人的订单
    select #SNPD.*, b.orderid as orderid into #porder
    from BASKET.. BaseOrderTracker b ( nolock) inner join #SNPD( nolock ) on b.PurchasedByContactID= #SNPD.contactId
    and b. OrderDate>'2014-2-1' and b .OrderDate< '2014-3-1' and b.OrderTypeID= 15 and b .StageID<> 10400 and  b .OESourceID= 2
    
    
    --订单最大值
    select #porder. orderid,max (o .StageID) as stageid into #odermax from #porder (nolock )
    inner join BASKET..OrderTrackerAudit o (nolock ) on o. OrderID = #porder.OrderID
    group by #porder.orderid
    
    --last
    select #porder.* ,#odermax .stageid into #last from #porder (nolock ), #odermax(nolock )
    where #odermax. orderid=#porder .orderid
    
    
    --仅查询
    select * from #last (nolock )
    where stageid= 10400
    
    
    --失败人员订单的STAGE分析
    select stageid, COUNT( orderid ) from #last( nolock )
    group by stageid
    order by stageid
    
    
    --失败人员订单的level分析
    select  com. PurchaserCareerLevelID,COUNT (com . OrderID) from  #last(nolock ) l inner join CosmeticOrderMaster (nolock ) com
    on l. orderid=com .orderid
    group by com.PurchaserCareerLevelID
    order by com.PurchaserCareerLevelID
    
    
    --成功订单的level分析
    select  com. PurchaserCareerLevelID,COUNT (com . OrderID) from  BASKET .. BaseOrderTracker( nolock ) bot inner join CosmeticOrderMaster (nolock ) com
    on bot. OrderID=com .orderid
    where OrderDate> '2014-2-1' and OrderDate<     '2014-3-1'  and OrderTypeID =15 and      OESourceID= 2
    and StageID = 10400
    group by com.PurchaserCareerLevelID
    order by com.PurchaserCareerLevelID
  • 相关阅读:
    特征选取1-from sklearn.feature_selection import SelectKBest
    使用K-S检验一个数列是否服从正态分布、两个数列是否服从相同的分布
    风控8-收码平台
    风控7-同盾设备指纹
    互联网黑产剖析_虚假号码
    风控3_iv算法详细解释
    woe_iv原理和python代码建模
    逾期30天和60天的回款概率
    (剑指Offer)面试题15:链表中倒数第k个结点
    (剑指Offer)面试题14:调整数组顺序使奇数位于偶数前面
  • 原文地址:https://www.cnblogs.com/monkeyfather/p/4037411.html
Copyright © 2011-2022 走看看