(There should be comma before which.)
The rule is:
The words “that” and “which” play a number of roles, and some of their roles cause little or no confusion. However, writers tend to misuse these words when they are being used as relative pronouns to introduce adjective clauses. Keeping a few simple rules in mind will help eliminate confusion and allow the writer to use these words correctly. These example sentences should give you an idea to start out with.
[i]The bedrooms that we painted during the summer look cheerful and bright.
The bedrooms, which we painted during the summer, look cheerful and bright.[/i]
Both of these sentences tell you about the bedrooms, but what the first sentence tells you is completely different from what the second one tells you. In the first sentence, you see several bedrooms but only the recently painted ones look cheerful and bright. The second sentence simply says that all the bedrooms looked cheerful and bright and mentions that they’ve been painted.
The Restrictive Clause
The adjective clause in the first sentence in the examples above (that we painted during the summer) is called a restrictive clause because it limits the meaning of the nouns it modifies. The restrictive clause introduces information that is essential to understanding the meaning of the sentence, and “that” is the relative pronoun normally used to introduce this clause.
The Nonrestrictive Clause
The adjective clause in the second of the two example sentences (which we painted during the summer) is called a nonrestrictive clause because the clause modifies the noun but does not necessarily limit its meaning. The nonrestrictive clause introduces information that could be helpful but is nonessential to the understand the sentence, and “which” is the relative pronoun usually used to introduce the nonrestrictive clause. The nonrestrictive clause, as you can see in the example above, should be separated from the rest of the sentence with commas.
Exception to the Rule
Like a number of grammatical rules in English as well as other languages, this one has an exception. The exception should only be used when a sentence has more than one dependent clause or when “that” has been used in another role. Take a look at the following example.
That idea, which has been discussed thoroughly, no longer needs to be addressed.
If “this,” “that,” “these,” or “those” has already been used to either as an adjective or to introduce the first clause, use “which” to introduce the next one, whether the information is essential or nonessential.