QueryMissingSO 082923

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

SELECT t1.[No_],t1.[Created Document No_],t1.[Created Document Type], t1.

[Imported
Date], t2.[Item No_],t2.No_,t2.[Line No_],format(ISNULL(t2.Quantity,0) ,'N', 'de-
de') AS 'OrderQty'
, t3.No_,t3.[Order No_],format(ISNULL((select Sum([Quantity]) from
[NAV_Production].[dbo].[supplyFORCE$Sales Invoice Line] l where l.[Document
No_]=t3.No_ and l.[No_]=t2.[No_]),0),'N', 'de-de') AS 'InvQty'
FROM [NAV_Production].[dbo].[supplyFORCE$TC-EDI Inbound Message Header] t1
left join [NAV_Production].[dbo].[supplyFORCE$TC-EDI Inbound Message Line] t2 on
t1.[No_]=t2.[Inbound Message No_]
left join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Header] t3 on t3.
[Order No_] =t1.[Created Document No_]
-- right join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Line] t4 on t3.
[No_] =t4.[Document No_]
-- right outer join on t2.[Item No_]=t4.[No_]
-- left join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Line] t5 on t2.
[Item No_]=t4.[No_]
where t1.[Imported Date] >='2023-01-01' and t1.[Status]=3 and t1.[Created
Document Type]=1
and t2.Quantity >(select Sum([Quantity]) from [NAV_Production].[dbo].
[supplyFORCE$Sales Invoice Line] l where l.[Document No_]=t3.No_ and l.[No_]=t2.
[No_])
and t3.No_ ='2188650'

---------------------------------------------------

SELECT t1.[No_],t1.[Created Document No_],t1.[Created Document Type], t1.[Imported


Date], t2.[Item No_],t2.No_,t2.[Line No_],format(ISNULL(t2.Quantity,0) ,'N', 'de-
de') AS 'EDI Qty'
,(select isnull(Sum([Quantity]),0) from [NAV_Production].[dbo].[supplyFORCE$Sales
Invoice Line] l where l.[Document No_] in (select [No_] from
[NAV_Production].[dbo].[supplyFORCE$Sales Invoice Header] k where
k.[Order No_]=t1.[Created Document No_]) and l.No_=t2.No_)AS 'InvQty'
--and l.[No_]=t2.[No_]),0),'N', 'de-de') AS 'InvQty'
--, t3.No_,t3.[Order No_]
--, t4.No_,t4.Quantity
FROM [NAV_Production].[dbo].[supplyFORCE$TC-EDI Inbound Message Header] t1
right join [NAV_Production].[dbo].[supplyFORCE$TC-EDI Inbound Message Line] t2 on
t1.[No_]=t2.[Inbound Message No_]
-- RIGHT join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Header] t3
-- on t3.[Order No_] =t1.[Created Document No_]
-- inner join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Line] t4 on t3.
[No_] =t4.[Document No_]
-- right outer join on t2.[Item No_]=t4.[No_]
-- left join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Line] t5 on t2.
[Item No_]=t4.[No_]
where t1.[Imported Date] >='2023-01-01' and t1.[Status]=3 and t1.[Created
Document Type]=1

--------------------------
SELECT t1.[No_],t1.[Created Document No_],t1.[Created Document Type], t1.[Imported
Date], t2.[Item No_],t2.No_,t2.[Line No_], ISNULL(t2.Quantity,0) 'EDI Qty'
,(select isnull(Sum([Quantity]),0) from [NAV_Production].[dbo].[supplyFORCE$Sales
Invoice Line] l where l.[Document No_] in (select [No_] from
[NAV_Production].[dbo].[supplyFORCE$Sales Invoice Header] k where
k.[Order No_]=t1.[Created Document No_]) and l.No_=t2.No_)AS 'InvQty'
--and l.[No_]=t2.[No_]),0),'N', 'de-de') AS 'InvQty'
--, t3.No_,t3.[Order No_]
--, t4.No_,t4.Quantity
FROM [NAV_Production].[dbo].[supplyFORCE$TC-EDI Inbound Message Header] t1
right join [NAV_Production].[dbo].[supplyFORCE$TC-EDI Inbound Message Line] t2 on
t1.[No_]=t2.[Inbound Message No_]
-- RIGHT join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Header] t3
-- on t3.[Order No_] =t1.[Created Document No_]
-- inner join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Line] t4 on t3.
[No_] =t4.[Document No_]
-- right outer join on t2.[Item No_]=t4.[No_]
-- left join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Line] t5 on t2.
[Item No_]=t4.[No_]
where t1.[Imported Date] >='2023-01-01' and t1.[Status]=3 and t1.[Created
Document Type]=1
and t2.Quantity >(select isnull(Sum([Quantity]),0) from [NAV_Production].[dbo].
[supplyFORCE$Sales Invoice Line] l where l.[Document No_] in (select [No_] from
[NAV_Production].[dbo].[supplyFORCE$Sales Invoice Header] k where
k.[Order No_]=t1.[Created Document No_]) and l.No_=t2.No_)

------------------------------
SELECT t1.[No_],t1.[Created Document No_],t1.[Created Document Type], t1.[Imported
Date], t2.[Item No_],t2.No_,t2.[Line No_], ISNULL(t2.Quantity,0) 'EDI Qty'
,(select isnull(Sum([Quantity]),0) from [NAV_Production].[dbo].[supplyFORCE$Sales
Invoice Line] l where l.[Document No_] in (select [No_] from
[NAV_Production].[dbo].[supplyFORCE$Sales Invoice Header] k where
k.[Order No_]=t1.[Created Document No_]) and l.No_=t2.No_)AS 'InvQty'
--and l.[No_]=t2.[No_]),0),'N', 'de-de') AS 'InvQty'
--, t3.No_,t3.[Order No_]
--, t4.No_,t4.Quantity
FROM [NAV_Production].[dbo].[supplyFORCE$TC-EDI Inbound Message Header] t1
right join [NAV_Production].[dbo].[supplyFORCE$TC-EDI Inbound Message Line] t2 on
t1.[No_]=t2.[Inbound Message No_]
-- RIGHT join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Header] t3
-- on t3.[Order No_] =t1.[Created Document No_]
-- inner join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Line] t4 on t3.
[No_] =t4.[Document No_]
-- right outer join on t2.[Item No_]=t4.[No_]
-- left join [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Line] t5 on t2.
[Item No_]=t4.[No_]
where t1.[Imported Date] >='2023-01-01' and t1.[Status]=3 and t1.[Created
Document Type]=1
and t2.Quantity >(select isnull(Sum([Quantity]),0) from [NAV_Production].[dbo].
[supplyFORCE$Sales Invoice Line] l where l.[Document No_] in (select [No_] from
[NAV_Production].[dbo].[supplyFORCE$Sales Invoice Header] k where
k.[Order No_]=t1.[Created Document No_]) and l.No_=t2.No_) order by [Created
Document No_]

--------------------------
select * from [NAV_Production].[dbo].[supplyFORCE$Sales Line] where [Document
No_]='30884204' order by [No_]

select * from [NAV_Production].[dbo].[supplyFORCE$Sales Invoice Line] where


[Document No_]='2188650' order by [No_]
select * from [NAV_Production].[dbo].[supplyFORCE$TC-EDI Inbound Message Line]
where [Inbound Message No_]='2463866' order by [No_]

select * from [NAV_Production].[dbo].[supplyFORCE$TC-EDI Inbound Message


Header] where [No_]='2463866'

You might also like