I had a query that was working, but when I added a DISTINCT to it started throwing an error. The error I was receiving was ORA-01791: not a SELECTed expression. It didn't give me which field it didn't like, so I was confused.
What I found was that once DISTINCT was in play all the fields in my ORDER BY had to be in the SELECT. All of the ORDER BY fields had to be fields and not calculations.