Join on Multiple Criteria with Or Statement

Comments

4 comments

  • Sabeel

    Hi Joshua,

     

    Could you please provide some example of this problem statement, just to interpret this query accurately?

    Regards,

    Sabeel

    0
    Comment actions Permalink
  • Joshua Barnett

    Below is an example. I need to join based on Customer Number or Customer Identifier to pull in the "data to be pulled in Join" column in the right table (left join). You can see sometime there is a match on only number or identifier in the original table. I do not see an easy way to accomplish this.

    0
    Comment actions Permalink
  • Joel Stewart

    What do you expect the output to look like if a record matches both values? Is there any time where a record would match differently between the Customer Number and Customer Identifier? Also, what size are the data sets? This can influence how complex a solution should be versus how performant. 

    My initial thoughts are to join based on the Customer Number only. Independently join on the Customer Identifier. Then union these two sets and use grouping to eliminate potential duplicates. 

    1
    Comment actions Permalink
  • Joshua Barnett

    This strategy should work. Thanks. The identifier and number should always be linked to the same person.

    0
    Comment actions Permalink

Please sign in to leave a comment.