3 Replies Latest reply: Jun 26, 2014 8:38 AM by Alex Hamilton McLeod RSS

    Incorrect join

      I'm a bit of a beginner at this and am trying to do a join between two tables

       

      My script below seems to assign each contact every value of the Contact Record Type. Obviously each contact should only have one record type though.

       

      Any ideas what i'm doing wrong?

       

       

      QUALIFY *;

      UNQUALIFY Activity.ConatctRecordTypeId;

      UNQUALIFY Activity.AccountId;

      UNQUALIFY Activity.ContactId;

      UNQUALIFY Activity.Department_Role__c;

      UNQUALIFY Activity.Business__c;

      Contacts:

      LOAD Id as Activity.ContactId,

          AccountId AS Activity.AccountId,

          Name,

          RecordTypeId AS Activity.ConatctRecordTypeId,

          CreatedDate,

          Department_Role__c AS Activity.Department_Role__c,

          Business__c AS Activity.Business__c,

          Asset_Class__c,

          Inactive_Contact__c,

          Region__c;

      SQL SELECT *

      FROM Contact

      WHERE RecordTypeId NOT IN ('012w000000063XQ','012w000000063qu');

      UNQUALIFY *;

       

       

       

       

      //Contact Record Types

      QUALIFY *;

      UNQUALIFY Activity.ContactRecordTypeId;

      ContactRecordType:

      LEFT JOIN (Contacts)

      ContactRecordType:

      LOAD Id AS Activity.ConatctRecordTypeId,

          Name;

      SQL SELECT *

      FROM RecordType

      WHERE SobjectType IN ('Contact');

      UNQUALIFY *;