The code you posted, cannot run. You cannot specify order by in a CTE. Also, your CTE is useless, it adds no value because you just select * on it with a condition.
Make sure the values you are doing checks on, are indexed.
from F009011 a
left outer join F009011 b
on b.CustNo!=a.CustNo
THIS is expensive, it asks for a join of most of the table against every row. You need to rethink your approach. How many rows do you have ? What is the business need here ?