moved projection and duplicate elimination before order by
this now adheres to the commonly accepted order of operators