So if you go to customers in D365, addresses tab - Advanced
you'll be able to see active or history addresses

so right now i have active and history addresses that are all primary.
So if i do the following: i will get 4 primary addresses even though i only have one primary that is active
select *from CUSTINVOICEJOUR
inner join CUSTTABLE
on CUSTTABLE.ACCOUNTNUM = CUSTINVOICEJOUR.ORDERACCOUNT
inner join DIRPARTYLOCATION
on DIRPARTYLOCATION.PARTY = CUSTTABLE.PARTY
inner join LOGISTICSPOSTALADDRESS
on LOGISTICSPOSTALADDRESS.LOCATION = DIRPARTYLOCATION.LOCATION
where CUSTTABLE.DATAAREAID = 'usmf' and DIRPARTYLOCATION.ISPRIMARY=1 and CUSTINVOICEJOUR.DATAAREAID = 'usmf'
and CUSTINVOICEJOUR.INVOICEID = 'CIV-000001' and CUSTINVOICEJOUR.ORDERACCOUNT = 'de-001'