Hi all,

I'm trying to use an outer join on a table in an aggregate x++ select 
statement but AX doesn't seem to like it and an inner join is forced. 

the X++ statement looks like this:
   select
     AccountNum
   from
     vendTable group by AccountNum
     outer join maxOf(Name) from contactPerson
     join count(RecId) from purchTable
   where
     vendTable.AccountNum == purchTable.OrderAccount
     && vendTable.ContactPersonId == contactPerson.ContactPersonId
     && (purchTable.FEB_ReturnType == FEB_POReturnType::Box
        || purchTable.FEB_ReturnType == EB_POReturnType::Collection
        || purchTable.FEB_ReturnType == FEB_POReturnType::None)

the equivalent T-SQL statement looks like this:
   select
     a.AccountNum,
     max(isnull(c.Name,'')) as ContactPersonName,
     count(b.PurchId) as POCount
   from
     bmssa.VendTable a inner join bmssa.PurchTable b on a.DataAreaId
     = b.DataAreaId and a.AccountNum = b.OrderAccount
     left outer join bmssa.ContactPerson c on a.DataAreaId =
     c.DataAreaId and a.ContactPersonId = c.ContactPersonId
where
        a.DataAreaId = 'dat'
        and b.FEB_ReturnType in (0,2,3)
group by
        a.AccountNum

Any takers?

Kind regards,

Christoph 

Reply via email to