ORDER BY in subqueries not being enforced in outer query