Multiply both sides by $(x^2+1)(x^2+2)$:
\[
2x^4 - 3x^2 + 4 = a(x^2+1)(x^2+2) + (px+q)(x^2+2) + (mx+n)(x^2+1).
\]
Expand right side and group coefficients by powers of $x$. Equate coefficients of powers $x^4, x^3, x^2, x, 1$ on both sides.
From the system of equations, solve for $a, p, q, m, n$. Finally, compute ratio $\frac{n}{q} = p + m - a$.