There are four tenses in the French subjunctive, the present, the past, the imperfect, and the pluperfect. This represents a small range of tenses as compared to the indicative, which has eight tenses.
In ordinary conversation and writing, only the present and past subjunctive are used. The names are misleading, however, because the present subjunctive can be used for events which actually took place in the past; what is important is when they take place relative to the main clause.
Je suis content que vous soyez venu.
J'étais content que vous veniez.
In the first sentence, "I am happy that you came," the past subjunctive is used because the event (coming) took place before the main verb (to be happy). In the second, the two verbs occur at the same time and therefore the present subjunctive is used, even though the action it refers to took place in the past.
The rule, therefore is that the present subjunctive is used for events that take place at the same time as or after the main clause, and the past subjunctive is used for events that take place prior to the main clause.
In literary or formal usage, however, this becomes more complicated, because two more tenses come into play. If the main verb is in the present tense or the future, then the present or past subjunctive are used, as above. If however, the main clause is in the past tense, then the imperfect and the pluperfect are used. Examples:
1. Je suis content que tu restes.
2. Je suis content que tu sois resté.
3. J'étais content que tu restasses.
4. J'étais content que tu fusses resté.
In both the first and third sentences, the subordinate clause takes place at the same time as the main clause, but in 3 the imperfect subjunctive is used because the main clause is in the past tense. In 2 and 4 the subordinate occurs before the main clause, but in 4 the pluperfect subjunctive is used, because the main clause is in the past. Note that in non-literary style "restasses" would be replaced by "restes" and "fusses resté" by "sois resté."
WARNING: Do not use the imperfect or pluperfect subjunctive in speech or in writing unless you happen to be writing a masterpiece of French literature, or you will be mistaken for a pedant, a snob, a fool, or worse. Stick to the present and past subjunctive; that's a big enough task for most non-native speakers.