How can I join the Sales Header and Sales Invoice Header in a single query and only return a distinct selection of order no's? I started with an Union query but it is not getting me a distinct list of all orders. Here is what I have so far:
Select SIH.[Order Date],
Case SIH.[Order Type]
When 0 Then 'Catalog'
When 1 Then 'Wholesale'
End,
SIH.[Order No_],
'SIH'
From [SWKTestWeb$Sales Invoice Header] As SIH
Where SIH.[Order Date] between '09/01/09' and '09/30/09' and SIH.[Order No_] <> ''
Union
select SH.[Order Date],
Case SH.[Order Type]
When 0 Then 'Catalog'
When 1 Then 'Wholesale'
End,
SH.No_,
'SH'
From [SWKTestWeb$Sales Header] as SH
Where SH.[Document Type] = 1
Any thoughts?
0
Comments
Doesn't the following code run correctly?
Dynamics NAV Developer since 2005
jwilder@stonewallkitchen.com
http://mibuso.com/blogs/davidmachanick/