select
PIH.[No_] as [Document No]
,PIH.[Pre-Assigned No_] as [Original No]
,PIL. [Description]
,(PL.[Outstanding Quantity]*PL.[Direct Unit Cost]) as Dispute_Amt
,100*(COALESCE(PL.[Outstanding Quantity]*PL.[Direct Unit Cost] / NULLIF(PL.[Amount],0), 0) ) as [Dispute%]
,PIH.[Buy-from Vendor Name]
,PIH.[Buy-from Vendor No_]
,PH."Creation Date"
,PH."Expected Receipt Date" as [Actl.Posting Date]
,PH."Document Date"
,PIH.[Notes] as [Header Notes]
,(PL.[Outstanding Quantity] *PL.[Direct Unit Cost]) as [Tolerance Amount]
,100*(COALESCE(PL.[Outstanding Quantity]*PL.[Direct Unit Cost] / NULLIF(PL.[Amount],0), 0) ) as [Tolerance%]
,PL.[Document No_] as [P.O.Number]
,PL.[Original Quantity] as [PO.Quantity]
,PL.[Amount] as [PO Value]
,PL.[Quantity Received] as [Delivered Qty]
,PL.[Quantity Invoiced] as [Invoiced Qty]
,PL.[Return Qty_ to Ship] as [Return Qty]
,PL.[Outstanding Quantity]
,PL.[Direct Unit Cost]
from [ Trading$Purch_ Inv_ Header] PIH
Inner join [Trading$Purch_ Inv_ Line] PIL
ON PIH.[No_]=PIL.[Document No_]
inner join [Trading$Purchase Header] PH
ON PH.[No_]=PIH.[PO Number]
inner join [Trading$Purchase Line] PL
On PL.[Document No_]=PH.[No_]
where
PIL.[No_] in ('170050','700220','700300')
[如果我使用此代码我获得4500条记录,但我想通过删除重复的PIH [Document_No]与PIL [No _]的170050,700220,700300过滤结果集,发票问题如缺货,发票纠纷金额等,即没有争议的记录为零。
有什么帮助吗?
]
答案 0 :(得分:0)
WHERE PL。[未结数量] * PL。[直接单位成本]不为空 和PL。[未付数量] * PL。[直接单位成本]<> 0