• sharonsql2013 (5/18/2015)


    Is it possible to join based on conditions

    I am trying to join Project_Code with Manager.Code but if the project_code is blank then it should look for Project_CostCenter and Join with ManagerCode .

    Project_Code = Manager.Code ( But if Project_Code is blank)

    Then Project_Cost_Center = Manager.code

    I tried COALESCE but somehow my results don't show as expected, also the Projectcode is blank and not Null

    Please post your code so we can try to figure something else out because conditional joins typical result in some pretty slow performance and pretty high resource usage.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)