Performing a loop or for I need to?

  • It's been ages since I needed to perform one of these but I think I need to now.

    1) I need to pull a query of accounts, one account can have many contacts, a contact can have many accounts.

    2) I need to pull the most recent contact (as determined by the max of their ID number)

    3) ***A contact can only appear once in the query ie if Contact 100 is attached to account a, f, d he can only appear as the contact for account a, for account d we need to find the next available contact.

    I'm totally at a loss as to how to perform this...hope I provided enough info

    Any help or advice is greatly appreciated


  • Thanks for all the help.

    I've attached the sample data.

    After loading all the data you will see that Contact Ali Abounnaim is authorized in all accounts and has the highest ContactNo=100757289

    For the first account (Classic Audi determined by account name asc) we are fine with him being the contact as the highest ContactNo. For the second account - Classic Drivers Mart - Ali Abounnaim id now ineligible since he is already on the list for Classic Audi. For Classic Audi we would want contact 100567760 Jamie Khaner as the next highest authorized Contact.

    Trying to figure out how to do this properly. Go through each record and make sure the contact is not already in the list, if so move on to the next contact.

    Make sense?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply