Judgment may be given for or against one or more of several plaintiffs, and for or against one or more of several defendants; and it may, when the justice of the case requires it, determine the ultimate rights of the parties on each side, as between themselves.