• First, I reformatted the code to use ANSI-92 style joins instead of ANSI-89 style joins. Did this to verify that there was no accidental cross join due to a missing join.

    select DISTINCT

    B0.PARTNER,

    B0.NAME_ORG1,

    B0.NAME_ORG2

    from

    pvc.CRMD_TERR_ACCREL TA

    INNER JOIN pvc.BUT000 B0

    on (TA.PARTNER_GUID = B0.PARTNER_GUID)

    INNER JOIN pvc.CRMM_TERRITORY ct

    on (TA.TERR_GUID = ct.TERR_GUID)

    INNER JOIN pvc.CRMM_BUT_LNK0031 CB

    on (B0.PARTNER_GUID = CB.PARTNER_GUID)

    INNER JOIN pvc.HRP1000 HP

    on (CB.SALES_ORG = HP.OTJID)

    INNER JOIN pvc.CRMD_TERR_LINK TL

    on (TA.RULE_ID = TL.RULE_ID)

    INNER JOIN pvc.BUT100 B1

    on (B0.PARTNER = B1.PARTNER)

    WHERE

    TA.VALID_TO = '99991231' AND

    ct.TERR_ID = '00099' AND

    B0.XBLCK <> 'X' AND

    B1.RLTYP ='ZFODLR' or

    B1.RLTYP ='ZINDLR'

    ORDER BY

    B0.NAME_ORG1 ASC;

    Next, the WHERE clause is interesting since there is an OR in there. As written all rows where B1.RLTYP = 'ZINDLR' will be returned as part of the result set.