bug in ordering subquery