Comparison of integrals
Under what conditions on $f$ can we conclude the following inequality:
$$\left(\int_a^b f \, \mathrm{d}x\right)^2 \leq \int_a^b f^2 \, \mathrm{d}x.$$
Cauchy-Schwarz looked appealing at first: $$\left(\int_a^b fg \, \mathrm{d}x \right)^2 \leq \left(\int_a^b f^2 \, \mathrm{d}x\right)\left(\int_a^b g^2 \, \mathrm{d}x\right).$$ Setting $g \equiv 1$, we get $$\left(\int_a^b f \, \mathrm{d}x \right)^2 \leq (b-a)\left(\int_a^b f^2 \, \mathrm{d}x\right),$$ so if $b - a \leq 1$, we are done. But what about for more general intervals? I think the answer lies in a more clever substitution/manipulation. Feel free to cite as many powerful inequalities as you want. All integration is done in the Riemann sense, but answers with Lebesgue are welcome.
For $f \in L^2[a,b]$ we have, $$\left(\frac{1}{b-a}\int_a^b f \, \mathrm{d}x\right)^2 \leq \frac{1}{b-a}\int_a^b f^2 \, \mathrm{d}x.$$ by Jensen's Inequality for integrals. ($\phi(x)=x^2$ is convex.)
This implies, $$\left(\int_a^b f \, \mathrm{d}x\right)^2 \leq (b-a)\int_a^b f^2 \, \mathrm{d}x.$$ Therefore, if we have $(b-a) \leq 1$ then we have the original inequality. On the other hand suppose the inequality hold for all $f \in L^2[a,b]$ then $f(x)=1$ yields $(b-a)^2 \leq (b-a) \implies (b-a) \leq 1$.
Hence, the condition $(b-a)\leq 1$ is sufficient and necessary.
$\textbf{Edit}:$ The equality here occurs if and only if $f$ is constant. So, we should have strict inequality if $f$ is non-constant.