Fix combination of DISTINCT and ORDER BY.