Example of differentiable function with derivative 0 but not constant
$$\begin{align*} f: \Q &\to \Q \\ x &\mapsto \begin{cases} 0, &x^2 < 2. \\ 1, &x^2>2. \end{cases} \end{align*}$$
$$\begin{align*} f: \Q &\to \Q \\ x &\mapsto \begin{cases} 0, &x^2 < 2. \\ 1, &x^2>2. \end{cases} \end{align*}$$