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

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

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

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

您需要登录以后才能回答，未注册用户请先注册