Could you please lookinto the following issue of Customer and Sites issue.
I'm using the below query to fetch the records and i'm inserting into one staging table ,then updating process flag to 'Y". then in case of any modifications on the customer level or site level then that/those records should come and again we need to insert into the same table.
But here it is coming but one condtion it is failing like.. one party_id having multiple customers then the last party_id and customer numbers are overwritting to the previous colmns data.
EG: just create same customer name with differerent cutomer numbers. with sites.. you will come to know the issue.