未发货查询 修订

This commit is contained in:
杰 朱
2021-12-06 11:25:43 +08:00
parent e6ab4d5c0c
commit 17e26be475
3 changed files with 33 additions and 8 deletions

View File

@@ -860,7 +860,7 @@ select *from tempdb..tablepzck20210526
,
isnull(cs.qty,0) as xcl,
b.cVerifier
,
,case when (
isnull(
(SELECT isnull(SUM(iquantity),0) qty
FROM currentstock WITH (nolock) where cInvCode=a.cInvCode
@@ -872,7 +872,19 @@ select *from tempdb..tablepzck20210526
GROUP BY ipesodid) dd on isnull(dd.ipesodid,'')=isnull(aa.iSOsID ,'')
where aa.cInvCode=a.cInvCode and bb.cVerifier is not null and isnull(CONVERT(varchar(100),aa.dPreDate, 23),'1900-01-01')<=isnull(CONVERT(varchar(100),a.dPreDate, 23),'1900-01-01') and (aa.iQuantity - isnull(dd.cqty,0))>0
group by aa.cInvCode
) as kcyl
) )>0 then 0 else (
isnull(
(SELECT isnull(SUM(iquantity),0) qty
FROM currentstock WITH (nolock) where cInvCode=a.cInvCode
GROUP BY cInvCode
),0)-( select sum(aa.iQuantity - isnull(dd.cqty,0)) as swfiQuantity from SO_SODetails aa WITH (nolock) LEFT JOIN
SO_SOMain bb WITH (nolock) on aa.ID=bb.id left join
(SELECT ipesodid, sum(iQuantity) AS cqty
FROM rdrecords32 WITH (nolock)
GROUP BY ipesodid) dd on isnull(dd.ipesodid,'')=isnull(aa.iSOsID ,'')
where aa.cInvCode=a.cInvCode and bb.cVerifier is not null and isnull(CONVERT(varchar(100),aa.dPreDate, 23),'1900-01-01')<=isnull(CONVERT(varchar(100),a.dPreDate, 23),'1900-01-01') and (aa.iQuantity - isnull(dd.cqty,0))>0
group by aa.cInvCode
) ) end as kcyl
,
CONVERT(varchar(100),a.dPreDate, 23) as dPreDate , a.cMemo,
CASE
@@ -889,11 +901,13 @@ select *from tempdb..tablepzck20210526
GROUP BY ipesodid) d on d.ipesodid=a.iSOsID
left join
(SELECT cinvcode, SUM(iquantity) qty
FROM currentstock WITH (nolock)
FROM currentstock WITH (nolock) where cWhCode not in (4,5)
GROUP BY cInvCode) cs ON a.cInvCode = cs.cInvCode
left join Customer f WITH (nolock) on b.cCusCode=f.cCusCode
left join Inventory g WITH (nolock) on g.cInvCode=a.cInvCode ) mm