2. Let $x, y, z$ be pairwise distinct real numbers, and
$$
\sqrt{z(x-z)}+\sqrt{z(y-z)}=\sqrt{x-z}-\sqrt{z-y} \text {, }
$$

then $\frac{3 x^{2}+x y-y^{2}}{x^{2}-x y+y^{2}}=$ $\qquad$
2. $\frac{1}{3}$.

From the given, we have
$$
\left\{\begin{array}{l}
z(x-z) \geqslant 0, \\
z(y-z) \geqslant 0, \\
x-z \geqslant 0, \\
z-y \geqslant 0 .
\end{array}\right.
$$

From (9) and (1), we get $z \geqslant 0$;
From (3) and (2), we get $z \leqslant 0$.
Thus, $z=0$.
Substituting $z=0$ into the given equation, we get
$$
\begin{array}{l}
\sqrt{x}-\sqrt{-y}=0 . \\
\therefore \quad x=-y .
\end{array}
$$

Substituting $x=-y$ into the given equation, we get
$$
\begin{array}{l}
\frac{3 x^{2}+x y-y^{2}}{x^{2}-x y+y^{2}} \\
=\frac{3 x^{2}-x^{2}-x^{2}}{x^{2}+x^{2}+x^{2}}=\frac{x^{2}}{3 x^{2}}=\frac{1}{3} .
\end{array}
$$