I think of the contingency table test. In all textbooks I've seen, the test statistic is calculated as the sum of $(O-E)^2/E$ over all cells. But the degree of freedom is not the number of all cells. E.g. in an $n \times m$ table, it's $(n-1)(m-1)$.
So far so good. But what's the rationale behind this approach? I think that the definition of the $\chi^2$ distribution is the sum of $M$ variables, each a square of a standard normal variable. I think that each $(O-E)^2/E$ is approximately standard normal, and that's why we use $\chi^2$ distribution. But the degree of freedom is not the number of summands!