Bernoulli's equation is valid along a streamline for inviscid flow - where there isn't any friction or loss of stagnation pressure.
You need to instead look at the loss of stagnation pressure for fully developed turbulent flow (assuming the pipe is very long, and that the fluid is incompressible)
Velocity is constant for an incompressible fluid if the pipe has constant area, because the mass flow rate $\dot{m}=\rho VA$.
So to get the pressure drop, you use the Darcy-Weisbach equation, $\frac{\Delta P}{L}=\frac{1}{2}\frac{\rho V^2}{D}f$, where $D$ is the pipe diameter and $f$ is the friction factor, which is given in charts like the one at https://www.pipeflow.com/pipe-pressure-drop-calculations/pipe-friction-factors
If the pipe is leaving into a big tank, there'll be an additional stagnation pressure loss of $\Delta P=\frac{1}{2}\rho V^2$ for the exit, because the dynamic pressure isn't being recovered, but for very long pipes this becomes comparatively small.
So the friction factor $f$ depends on how rough the pipe walls are - for a pipe with bumps that are about 1% of the diameter, it's about 0.04 for fully turbulent flows (at long distances)
So to calculate the velocity, ignoring the little bits where it's not fully turbulent and the exit loss, you'd get $V=\sqrt{\frac{2\Delta PD}{\rho Lf}}$.
There's no maximum distance - the velocity just decreases with lower pressure and longer length. There'll always be some flow. But at very low velocities, the turbulent assumption breaks down and the maths gets harder.
Also if you're pumping something compressible like a gas, you get all sorts of weirdness where the gas expands as the pressure goes down and it heats up, so velocity increases, up to the speed of sound sometimes, as it goes and the maths gets horrible.