We consider a general continuous mean-variance problem where the cost functional has an integral and a terminal-time component. We transform the problem into a superposition of a static and a dynamic optimization problem. The value function of the latter can be considered as the solution to a degenerate HJB equation either in viscosity or in Sobolev sense (after regularization) under suitable assumptions and with implications with regards to the optimality of strategies.