Fix query order.