首页 > 代码库 > SQL Server 订单分析
SQL Server 订单分析
select distinct PurchasedByContactID as PurchasedByContactID into #SPfrom BASKET.. BaseOrderTracker(nolock )where OrderDate> ‘2014-2-1‘ and OrderDate< ‘2014-3-1‘ and OrderTypeID =15 and OESourceID= 2and StageID= 10400select distinct PurchasedByContactID as PurchasedByContactID into #Pfrom 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 awhere 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 contactIdinto #SNPDfrom 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 #porderfrom BASKET.. BaseOrderTracker b ( nolock) inner join #SNPD( nolock ) on b.PurchasedByContactID= #SNPD.contactIdand 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.OrderIDgroup by #porder.orderid--lastselect #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 stageidorder by stageid--失败人员订单的level分析select com. PurchaserCareerLevelID,COUNT (com . OrderID) from #last(nolock ) l inner join CosmeticOrderMaster (nolock ) comon l. orderid=com .orderidgroup by com.PurchaserCareerLevelIDorder by com.PurchaserCareerLevelID--成功订单的level分析select com. PurchaserCareerLevelID,COUNT (com . OrderID) from BASKET .. BaseOrderTracker( nolock ) bot inner join CosmeticOrderMaster (nolock ) comon bot. OrderID=com .orderidwhere OrderDate> ‘2014-2-1‘ and OrderDate< ‘2014-3-1‘ and OrderTypeID =15 and OESourceID= 2and StageID = 10400group by com.PurchaserCareerLevelIDorder by com.PurchaserCareerLevelID
SQL Server 订单分析
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。