Contrary to static mean-variance analysis, very few papers have dealt with dynamic mean-variance analysis. Here, the mean-variance efficient self-financing portfolio strategy is derived for n risky assets in discrete and continuous time. In the discrete setting, the resulting portfolio is mean-variance efficient in a dynamic sense. It is shown that the optimal strategy for n risky assets may be dominated if the expected terminal wealth is constrained to exactly attain a certain goal instead of exceeding the goal. The optimal strategy for n risky assets can be decomposed into a locally mean-variance efficient strategy and a strategy that ensures optimum diversification across time. In continuous time, a dynamically mean-variance efficient portfolio is infeasible due to the constraint on the expected level of terminal wealth. A modified problem where mean and variance are determined at t=0 was solved by Richardson (1989). The solution is discussed and generalized for a market with n risky assets. Moreover, a dynamically optimal strategy is presented for the objective of minimizing the expected quadratic deviation from a certain target level subject to a given mean. This strategy equals that of the first objective. The strategy can be reinterpreted as a two-fund strategy in the growth optimum portfolio and the risk-free asset.