added support for referencing distinct return expressions in order by