Let the number of students in the first group be $x$, and the number of students in the second group be $y$.
The total marks for the first group is $30x$, since the average marks of the first group is 30.
The total marks for the second group is $40y$, since the average marks of the second group is 40.
When both groups are combined, the total number of students is $x + y$, and the total marks is $30x + 40y$.
The average score of the combined group is 34, so:
$ \frac{30x + 40y}{x + y} = 34 $
Now, multiply both sides of the equation by $x + y$:
$ 30x + 40y = 34(x + y) $
Expand both sides:
$ 30x + 40y = 34x + 34y $
Rearrange the equation:
$ 30x - 34x = 34y - 40y $
Simplify:
$ -4x = -6y $
Divide by $-2$:
$ 2x = 3y $
Thus, the ratio of the number of students in the first group to the second group is:
$ \frac{x}{y} = \frac{3}{2} $
So, the correct answer is 3 : 2.