Ticket #973: Fixing query order