Merge where clauses where possible