6. The students of Class 2, Grade 8 participated in a community public welfare activity - collecting used batteries. Among them, the students in Group A collected an average of 17 each, the students in Group B collected an average of 20 each, and the students in Group C collected an average of 21 each. If these three groups collected a total of 233 used batteries, then the total number of students in these three groups is ( ) people.
(A) 12
(B) 13
(C) 14
(D) 15
6.A.

Let the number of students in groups A, B, and C be $x$, $y$, and $z$ respectively. From the problem, we have
$$
17 x+20 y+21 z=233 \text {. }
$$

Since $233=17 x+20 y+21 z>17 x+17 y+17 z$, then $x+y+z<\frac{233}{17}=13 \frac{12}{17}$, and $x+y+z>\frac{233}{21}=11 \frac{2}{21}$.
Thus, $11 \frac{2}{21}<x+y+z<13 \frac{12}{17}$.
Since $x$, $y$, and $z$ are all positive integers, then $x+y+z=12$ or $x+y+z=13$.
(1) When $x+y+z=13$, from the system of equations
$$
\left\{\begin{array}{l}
x+y+z=13, \\
17 x+20 y+21 z=233,
\end{array}\right.
$$

eliminating $x$, we get $3 y+4 z=12$, which has no positive integer solutions.
(2) When $x+y+z=12$, from the system of equations
$$
\left\{\begin{array}{l}
x+y+z=12, \\
17 x+20 y+21 z=233,
\end{array}\right.
$$

eliminating $z$, we get $4 x+y=19$, which has positive integer solutions.
Therefore, $x+y+z=12$, meaning the three groups have a total of 12 students.
In fact, since $x$, $y$, and $z$ are all positive integers, and combining the system of equations $\left\{\begin{array}{l}x+y+z=12, \\ 4 x+y=19,\end{array}\right.$, we can solve to get
$$
(x, y, z)=(3,7,2),(4,3,5) \text {. }
$$