SQL Query over ODBC is slow with DISTINCT
This is a messy query, I personally don't like nesting a select statement in my joins, I would rather use a Common Table Expression like this

WITH csmax AS (
    SELECT CustomerID, MAX(CreateDate) AS MaxDate
        FROM PUB.CustomerSalesperson
        GROUP BY CustomerID
)
SELECT DISTINCT cs.CustomerID, cs.SalespersonID
    FROM PUB.CustomerSalesperson cs
    INNER JOIN csmax ON cs.CustomerID = csmax.CustomerID
    WHERE csmax.MaxDate = cs.CreateDate


This should help the DB run the query more efficiently as well.  using the with statement should allow the SQL Engine to create a table and then compare the tables the way they were meant to be compared.  The CTE actually prepares the table before the outer query is run, so we aren't doing this on the fly.



Sounds like you can't run this through the ODBC connection, I looked at the documentation that you linked me to and found a CREATE VIEW command that would probably have similar efficiency to using a CTE.

CREATE VIEW csmax (CustomerID, CreateDate) AS 
    SELECT CustomerID, MAX(CreateDate) AS MaxDate
        FROM PUB.CustomerSalesperson
        GROUP BY CustomerID ;

SELECT DISTINCT cs.CustomerID, cs.SalespersonID
    FROM PUB.CustomerSalesperson cs
    INNER JOIN csmax ON cs.CustomerID = csmax.CustomerID
    WHERE csmax.MaxDate = cs.CreateDate

DROP VIEW csmax


This code is more readable than the code that you wrote, it is easier to follow.  

First thing you want to do is get a list of all the customers and the most recent date they did whatever.

Then, you want to know which Sales Person is associated with the "whatever" that customer did at their most recent visit.