For $G$ is open bounded set in $\mathbf{R}^n$, $L_2(G)$ is defined as $$L_2(G) = \{f:G\rightarrow \mathbf{R} \text{ measurable}: \int |f|^2<\infty\}$$
Now, I want to prove that $f:\mathbf{R} \rightarrow \mathbf{R}$
$$ f(x) = \begin{cases} 1, & \text{if }x\in \mathbf{Q} \\ 0, & \text{if }x\notin \mathbf{Q} \end{cases} $$ is in $L_2(\mathbf{R})$
I can prove that $f$ is measurable via Borel Algebra or $\mathbf{X}=\big\{\emptyset,\mathbf{R},\mathbf{Q},\mathbf{R}-\mathbf{Q}\big\}$
But, how can we prove that the integral of $f$ is finite?
Since $f^2 = f$ and $f$ is a simple function (namely, $f = 1 \chi_{\mathbb{Q}}$), we have that
$$\int_{\mathbb{R}} f^2 dm = \int_{\mathbb{R}} f dm = 1 \cdot m(\mathbb{Q}) = 0$$
since $m(\mathbb{Q}) = 0$.