Reduce the query