To get the equation of a line $y = ax+b$ passing through a set of $n$ points $(x_i, y_i)$ using least squares formula, we have to solve the following system of linear equations to determine the coefficients, $a$ and $b$: $$\begin{cases} \sum_i{y_ix_i}-a\sum_i{x_i^2}-b\sum_i{x_i} = 0, \\ \sum_i{y_i}-a\sum_i{x_i}-bn= 0 \end{cases} $$ I want to use this formula to find the equation $y = b=\text{constant}$. That is, we substitute $a$ by $0$ in the system above to get: $$ \begin{cases} b = {\sum_i{y_ix_i}\over \sum_i{x_i}} \\ b = {\sum_i{y_i}\over n} \end{cases} $$
The second expression of $b$ is obvious.
Why did we get two expressions for $b$? which one should I use?