
296 N.W.2d 731 (1980)
Ted COOK, Plaintiff,
v.
John REZEK, Defendant, Third-Party Plaintiff and Appellant,
v.
D. R. JUFFER, Third-Party Defendant and Appellee.
No. 12746.
Supreme Court of South Dakota.
Considered on Briefs April 21, 1980.
Decided September 24, 1980.
*732 John P. Blackburn and Michael D. Stevens, Yankton, for defendant, third-party plaintiff and appellant.
Richard W. Sabers of Dana, Golden, Moore & Rasmussen, Sioux Falls, for third-party defendant and appellee.
WOLLMAN, Chief Justice.
Defendant and third-party plaintiff, Rezek, appeals from an order granting summary judgment in favor of third-party defendant, Juffer. We affirm.
On July 20, 1973, Rezek signed a contract for the sale of land to plaintiff Cook as negotiated by Juffer, a banker and licensed real estate broker. Rezek refused to complete the transaction, and Cook brought an action for specific performance. We held that the contract was binding and granted specific performance to Cook. Cook v. Rezek, 89 S.D. 667, 237 N.W.2d 18 (1975).
The present action was then filed by Cook alleging damages resulting from lost rents, issues and profits as a result of Rezek's breach of contract. Rezek answered and counterclaimed against Cook, alleging that Juffer had secretly acted as an agent for Cook and had made fraudulent representations to Rezek which caused Rezek to convey his land, damaging him in the amount of $86,400.00. Rezek then served Juffer with a third-party complaint realleging his cause of action as stated against Cook.
Juffer moved for summary judgment against Cook and Rezek, alleging that the decision in Cook v. Rezek, supra, barred the present action and that no genuine issue of fact remained. Subsequently, Rezek and Cook stipulated to dismiss with prejudice the action between them. The trial court later ruled that Cook v. Rezek, supra, was res judicata and granted summary judgment in favor of Juffer.
We recently held in Melbourn v. Benham, 292 N.W.2d 335, 337 (S.D.1980), that:
Res judicata bars a later suit that attempts to relitigate the same cause of action by the parties or one of the parties in privity to a party in the earlier suit. Collateral estoppel bars not the cause of action, but rather, relitigation of an essential fact or issue involved in the earlier suit.
We conclude that although the trial court ruled correctly in granting summary judgment, it should have used as the basis for its decision the concept of collateral estoppel.
Several tests must be made before the doctrine of collateral estoppel may be applied:
First, was the issue decided in the prior adjudication identical with the one presented in the action in question? Second, was there a final judgment on the merits? Third, was the party against whom the plea is asserted a party or in privity with a party to the prior adjudication? And, fourth, did the party against whom the plea is asserted have a full and fair opportunity to litigate the issue in the prior adjudication?
Pomeroy v. Waitkus, 183 Colo. 344, 517 P.2d 396, 399 (1973) (footnote omitted).
Only the first test as set forth in the Waitkus case need be discussed, for it is clear that the remaining three tests are satisfied.
In Melbourn we held that the complaint and the counterclaim raised separate and distinct issues that were not litigated in the prior action that involved one of the parties. Basically, the complaint alleged breach of the real estate listing contract by the realtors, and the counterclaim sought recovery *733 of the amount owed as a commission arising out of the performance of that listing contract. In the instant case, Rezek essentially is attempting to recover damages for having been required to perform what this Court earlier held to be a valid contract. As we said in our opinion in that case, "What the record does reveal is that the defendant, for personal reasons, realized that he really did not want to sell his land and was using the plaintiff's delay as an excuse for repudiating the contract." 237 N.W.2d at 21. Nothing could be more conducive to the spawning of a multiplicity of suits than for a court to hold that a party to a contract that has been judicially declared to be valid and binding can later be permitted to seek recovery from a third party for what may in retrospect appear to have been a bad bargain.
Rezek's third-party action against Juffer consisted of nothing more than a thinly veiled attempt to relitigate that which was conclusively decided by this Court in Cook v. Rezek. That the trial court may have entered summary judgment for the wrong reason does not bar this Court from affirming the judgment. Owens v. City of Beresford, 87 S.D. 8, 201 N.W.2d 890 (1972).
The order appealed from is affirmed.
DUNN and MORGAN, JJ., concur.
HENDERSON and FOSHEIM, JJ., dissent.
HENDERSON, Justice (dissenting).
Rezek's answer and counterclaim plainly allege false representations of Juffer; the counterclaim alleges concealment of an existing agency between Cook and Juffer.
The issues of fraud and agent misbehavior were not addressed in Cook v. Rezek, 89 S.D. 667, 237 N.W.2d 18 (1975) nor was Juffer a party thereto.
The lower court granted a motion for summary judgment in favor of Juffer and against Rezek based upon the doctrine of res judicata. This was error and I would reverse the trial court.
In Golden v. Oahe Enterprises, Inc., 90 S.D. 263, 276, 240 N.W.2d 102, 109 (1976), this court held that the doctrine of res judicata only applies to issues which have actually been litigated. In that decision, we stated:
If, however, the second action is based upon a different claim or demand, the prior judgment precludes further consideration only of those issues which are actually litigated and determined. (Emphasis supplied.)
In Cook v. Rezek, supra, the issues adjudicated were whether a contract existed and whether the remedy of specific performance should have been avoided. The pleadings before us in this case frame altogether different issues between different parties.
This Court set forth the principles of res judicata in Keith v. Willer's Truck Service, 64 S.D. 274, 266 N.W. 256 (1936). In that case, we compared res judicata as to a cause of action opposed to res judicata as to a particular issue of fact common to both actions. We stated:

First, a final judgment or decree of a court of competent jurisdiction upon the merits is a bar to any future action between the same parties or their privies upon the same cause of action, so long as it remains unreversed; and, second, a point which was actually and directly in issue in a former action and was there judicially passed upon and determined by a domestic court of competent jurisdiction cannot be drawn in question in any future action between the same parties or their privies whether the cause of action in the two actions be identical or different. (Citation omitted.) Under the first rule the res which is judicata is the cause of action. Under the second, the res which may be judicata is the particular issue or fact common to both actions. 64 S.D. at 276, 266 N.W. at 257-58. (Emphasis supplied.)
This action fits into the second category where the judicata is of a particular issue of common fact as opposed to a final adjudication "upon the merits" of the case as a whole.

*734 "There is a difference between the effect of a judgment as a bar or estoppel against the prosecution of a second action upon the same claim or demand, and its effect as an estoppel in another action between the same parties upon a different claim or cause of action." 64 S.D. at 275, 266 N.W. at 257.
The key in this case is that we have different parties and different causes of action. My point is aptly expressed in Keith, 64 S.D. at 276, 266 N.W. at 257:
"[W]hile a second and different cause of action may be defeated by a former judgment because it conclusively adjudicates some essential fact or issue involved in the latter, a judgment can never operate as a bar to a different cause of action. (Emphasis supplied.)
My review of this case further discloses that Juffer failed to factually refute the allegations of false representations. Juffer therefore failed to affirmatively assert a genuine issue of fact. Juffer's pleadings only generally deny the allegations of Rezek's pleadings. A hearsay affidavit by Juffer's attorney, which did not meet the criteria of SDCL 15-6-56(e), was not properly receivable as refutation of Rezek's causes of action. This affidavit was not submitted upon personal knowledge. The trial court erred in granting Juffer's motion for summary judgment as Juffer failed to affirmatively refute Rezek's allegations of false representations.
Res judicata is an affirmative defense; this defense was not pled in Juffer's answer. Nonetheless, the trial court based its decision on res judicata. SDCL 15-6-8(b) requires that it be asserted. Collateral estoppel, upon which this Court basis its decision, was neither pled nor urged. The majority has infused and inserted this totally new defense. Moreover, it has substituted it for the defense of res judicata which was never raised. I believe that this Court is restricted to reviewing those matters which are in issue at the trial court level. As regards collateral estoppel, it was theoretically impossible for the lower court to rule correctly or incorrectly because the trial court was never confronted with that issue. In Fales v. Kaupp, 83 S.D. 487, 161 N.W.2d 855 (1968), we held that the affirmative defense of waiver was not before the Supreme Court because it was not pleaded and was not an issue in the trial court. Therefore, collateral estoppel is not before this Court. This Court should not decide cases on theories it initially advances and which were not advanced at the trial court. It is unfair to the lawyers, the trial judges, and most importantly, the litigants. I agree with Chief Justice Wollman's 1972 dissent in the Owens case (which is now cited for authority to justify the Court's decision here) wherein he stated: "We should not now consider the question of the validity of ordinance No. 292 since that issue was not directly raised in the trial court." 201 N.W.2d at 894. (Emphasis added.)
Not only has Rezek not had his day in court on fraud and agent misbehavior, he has not had the opportunity to address collateral estoppel. Furthermore, if an affirmative defense is not pleaded, it is waived to the extent that the party who should have pleaded it may not introduce any evidence in support thereof. American Property Service, Inc. v. Barringer, 256 N.W.2d 887 (S.D.1977). Under the state of the pleadings, Juffer has no right to present any evidence to the trial court on res judicata or collateral estoppel.
FOSHEIM, Justice (dissenting).
The majority opinion distinguishes this case from Melbourn v. Benham, 292 N.W.2d 335 (S.D.1980), with this language: "In the instant case, Rezek essentially is attempting to recover damages for having been required to perform what this court earlier held to be a valid contract."
Following this court's reversal of the judgment in the original Cook v. Rezek litigation, the trial judge in that case described the issue decided therein as follows:
It seems clear to me that the only issue before me as a trial judge in the original matter was whether or not the Plaintiff, Ted Cook, had a valid contract with the Defendant, John Rezek.
. . . . .

*735 I think the record is clear that this court has never adjudicated the liability of Mr. Rezek under the contract. My concern, as it was the appellate court's concern, was simply to determine whether or not a valid contract had been struck between. . . [Cook and Rezek].
The third-party complaint in the present action alleged that Juffer secretly acted as an agent for Cook and made false representations to Rezek, thereby causing an agreement by Rezek to convey his land. That claim, strikingly similar to the allegation in Melbourn which claimed a breach of agency and fiduciary obligations by the Benhams in their capacity as real estate agents for Melbourn, was not litigated in the original Cook v. Rezek action. In Melbourn, we held that genuine issues of fact existed. Since the cases rest on similar grounds, it seems consistency compels recognition that genuine issues of fact remain.
In my view, the majority opinion's attempt to distinguish this case from Melbourn v. Benham, supra, draws unwarranted conclusions from disputed facts, conclusions similar to those we rejected in Melbourn. I would, therefore, reverse.
