• The reason might be the DISTINCT which has to sort all the values to eliminate duplicates. Another reason might be the OR you have in there which might be causing your query to return more rows than needed as it will return all rows where B1.RLTYP = 'ZINDLR' regardless of the other conditions.

    You have more tables than the ones that you're using and that might make the query to return duplicate rows. I'm not sure if you can remove those tables or if you need them to filter some values.

    I rearranged your query to use ANSI-92 Joins and I suggest you to use them to mantain a standard join when you need to use outer joins.

    SELECT DISTINCT B0.PARTNER

    ,B0.NAME_ORG1

    ,B0.NAME_ORG2

    FROM pvc.CRMD_TERR_ACCREL TA

    JOIN pvc.BUT000 B0 ON TA.PARTNER_GUID = B0.PARTNER_GUID

    JOIN pvc.CRMM_TERRITORY ct ON TA.TERR_GUID = ct.TERR_GUID

    JOIN pvc.CRMM_BUT_LNK0031 CB ON B0.PARTNER_GUID = CB.PARTNER_GUID --Not used

    JOIN pvc.HRP1000 HP ON CB.SALES_ORG = HP.OTJID --Not used

    JOIN pvc.CRMD_TERR_LINK TL ON TA.RULE_ID = TL.RULE_ID --Not used

    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')

    AND B1.RLTYP IN('ZFODLR', 'ZINDLR') --Same as above

    ORDER BY B0.NAME_ORG1 ASC;

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2