• It would still help if you could provide the DDL (CREATE TABLE statement) for the table(s) involved in the query, some sample data (INSERT INTO statements) for each of the table(s) involved, and the expected results based on the sample data.

    I am thinking this would be an easy rewrite if we could see what you see and what you actually want from the query.