One inequality about the average integral: $\bar{f}_A:=\frac{1}{\mu(A)} \int_A f \,d\mu$ For a measurable function $f$, if we consider the average integral:
$$\bar{f}_A:=\frac{1}{\mu(A)}\int_A f \, d\mu$$
where $\mu$ is Lebesgue measure.
\begin{equation}
     \begin{split}
         \int_A (f-\bar{f}_{A})^2\,d\mu
         &\leq \int_A (f-\bar{f}_{B})^2\,d\mu\\
         &\leq\int_B (f-\bar{f}_{B})^2\,d\mu
     \end{split}
 \end{equation}
where $A\subset B$. 

I am confused about how to get the first inequality? 

 A: $$
\int_A (f-\bar{f}_A)^2\,d\mu
\leq \int_A (f-\bar{f}_B)^2\,d\mu
$$
Maybe the best way to show this is by showing that for every real number $c$ we have
$$
\int_A (f- \overline f_A)^2 \, d\mu \le \int_A (f-c)^2 \, d\mu.
$$
Proof:
\begin{align}
\frac 1 {\mu(A)} \int_A (f-c)^2\,d\mu & = \frac 1 {\mu(A)} \int_A (f^2 - 2cf + c^2)\, d\mu \\[8pt]
& = \frac 1 {\mu(A)} \int_A f^2\,d\mu - \frac{2c}{\mu(A)} \int_A f\, d\mu + c^2 \\[8pt]
& = c^2 - 2pc + q \\[8pt]
& = (c^2 - 2pc + p^2) + q-p^2 \\[8pt]
& = (c-p)^2 + q-p^2
\end{align}
As $c$ varies, this very last expression is clearly smaller when $c=p$ than when $c={}$anything else. So notice that
$$
p = \overline f_A.
$$
A: $f-\overline {f}_B =(f-\overline {f}_A )+ (\overline {f}_A -\overline {f}_B )$. Square both sides and integrate over $A$. Note that the cross term vanishes: $2\int_A (f-\overline {f}_A )(\overline {f}_A -\overline {f}_B )=2(\overline {f}_A -\overline {f}_B ) \int_A (f-\overline {f}_A )$ and $\int_A(f-\overline {f}_A ) =0$. Can you finish?
