Revert "FIX for pgsql Invalid column reference"

This reverts commit 7ad54ebf64904cd919e5ac41c46372c65c2b28fe.
Removed unneeded orderby