–金蝶K3的销售订单和预测订单的分布情况
USE [AIS20101130170856]
GO
/****** Object: StoredProcedure [dbo].[test1124] Script Date: 03/29/2019 17:04:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter procedure [dbo].[sp_yx_dd]
as
declare @date1 as varchar(20)
declare @date2 as varchar(20)
declare @date3 as varchar(20)
declare @date4 as varchar(20)
declare @date5 as varchar(20)
declare @date6 as varchar(20)
declare @date7 as varchar(20)
declare @date8 as varchar(20)
declare @date9 as varchar(20)
declare @date10 as varchar(20)
declare @date11 as varchar(20)
declare @date12 as varchar(20)
set nocount on
select @date1=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate()),0),121),7)
select @date2=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+1,0),121),7)
select @date3=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+2,0),121),7)
select @date4=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+3,0),121),7)
select @date5=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+4,0),121),7)
select @date6=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+5,0),121),7)
select @date7=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+6,0),121),7)
select @date8=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+7,0),121),7)
select @date9=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+8,0),121),7)
select @date10=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+9,0),121),7)
select @date11=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+10,0),121),7)
select @date12=left(convert( varchar(20),dateadd(mm,datediff(mm,0,getdate())+11,0),121),7)
if object_id('tempdb..#test1124') is not null
drop table #test1124
select * into #test1124 from
(select convert(varchar(100),b.FDate,21) fldate ,b.fitemid,b.FAuxQty-b.FStockQty ddqty,'销售订单' fenlei
from SEOrder a inner join SEOrderEntry b on a.FInterID=b.FInterID
where a.FChangeMark=0 and b.FMRPClosed=0 and a.FCancellation=0
union all
select convert(varchar(100),FNeeddate ,21) fldate,
b.fitemid ,b.fqty-b.FAuxSelQty ,'预测订单' fenlei
from
PPOrder a
inner join PPOrderEntry b on a.finterid=b.finterid
where b.FOrderClosed=0 and (b.fqty-b.FAuxSelQty)>0 ) t
order by fldate
--
update #test1124
set fldate=convert(varchar(100),DATEADD(mm,datediff(mm,0,getdate()),0),21)
where FlDate