Fix ordering in query.