这个统计怎么写? ( 积分: 100 )

  • 主题发起人 主题发起人 fhp023
  • 开始时间 开始时间
谢谢jack391
我先调试一下,但结果不对,就是昨日库存和今日库存两个库存不对
再帮我看看是哪个地方错了,代码:
CREATE PROCEDURE [p_a] @DateT DateTime AS
select A.mc,Sum(B.qckc) +Sum(B.rsc)-Sum(B.rxh) as jrkc,sum(A.rsc) as rsc,
Sum(A.ysc) as ysc,Sum(A.nsc) as nsc,Sum(A.rxh) as rxh,Sum(A.yxh) as yxh,Sum(A.nxh) as nxh,
Sum(A.qckc)+Sum(A.rsc)-Sum(A.rxh) as zrkc
from T_aa A,T_aa B
where convert(char(10),A.t1,102)=convert(char(10),B.t1-1,102) and convert(char(10),B.t1,102)=convert(char(10),@DateT,102) and A.mc=B.mc
Group By A.mc
GO
 
我这样写了但库存不对啊,大家帮帮忙!谢谢
CREATE PROCEDURE [p_bb] @DateT DateTime AS
select A.mc,Sum(A.qckc)+Sum(A.rsc)-Sum(A.rxh) +Sum(B.rsc)-Sum(B.rxh) as jrkc,sum(B.rsc) as rsc, --Sum(B.qckc) +Sum(B.rsc)-Sum(B.rxh) as jrkc
Sum(B.ysc) as ysc,Sum(B.nsc) as nsc,Sum(B.rxh) as rxh,Sum(B.yxh) as yxh,Sum(B.nxh) as nxh,
Sum(A.qckc)+Sum(A.rsc)-Sum(A.rxh) as zrkc,Sum(B.qckc) as qckc
from T_aa A,T_aa B
where convert(char(10),A.t1,102)=convert(char(10),B.t1-1,102) and convert(char(10),B.t1,102)=convert(char(10),@DateT,102) and A.mc=B.mc
Group By A.mc
 
后退
顶部