fix order by for postgres