首页新闻找找看学习计划

这怎么相减 大神何在???采购申请单的数量-下推的数量

0
[已解决问题] 解决于 2015-08-10 16:34

select sum(FQty)as PR1 from PORequest a1 inner join PORequestEntry a2 on a1.FInterID=a2.FInterID where FStatus>0 and FCancellation=0
group by FItemID   采购申请单的数量

 

 

 

select sum(FQty)as PR2 from POOrder a3 inner join POOrderEntry a4 on a3.FInterID=a4.FInterID
where FCancellation=0 and FSourceTranType=70 group by FItemID

下推的数量

龙o魂的主页 龙o魂 | 初学一级 | 园豆:198
提问于:2015-08-10 15:26
< >
分享
最佳答案
0

试下下面这个

select A.PR1-B.PR2 from

(select sum(FQty)as PR1 from PORequest a1 inner join PORequestEntry a2 on a1.FInterID=a2.FInterID where FStatus>0 and FCancellation=0 
group by FItemID) as A

OUTER APPLY(select sum(FQty)as PR2 from POOrder a3 inner join POOrderEntry a4 on a3.FInterID=a4.FInterID 
where FCancellation=0 and FSourceTranType=70 group by FItemID) as B

奖励园豆:5
明Lam | 小虾三级 |园豆:595 | 2015-08-10 15:48
其他回答(1)
0

SELECT FItemID,PR1-PR2 FROM (
select FItemID,sum(FQty)as PR1 from PORequest a1 inner join PORequestEntry a2 on a1.FInterID=a2.FInterID where FStatus>0 and FCancellation=0
group by FItemID)A,
(select FItemID,sum(FQty)as PR2 from POOrder a3 inner join POOrderEntry a4 on a3.FInterID=a4.FInterID
where FCancellation=0 and FSourceTranType=70 group by FItemID)B
WHERE A.FItemID=B.FItemID

小白菜T | 园豆:564 (小虾三级) | 2015-08-10 16:05
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册