Electronic structure of Mg, Zn and Cd