We present a study on the clustering of a stellar mass selected sample of 18,482 galaxies with stellar masses M*>10^10M(sun) at redshifts 0.4<z<2.0, taken from the Palomar Observatory Wide-field Infrared Survey. We examine the clustering properties of these stellar mass selected samples as a function of redshift and stellar mass, and discuss the implications of measured clustering strengths in terms of their likely halo masses. We find that galaxies with high stellar masses have a progressively higher clustering strength, and amplitude, than galaxies with lower stellar masses. We also find that galaxies within a fixed stellar mass range have a higher clustering strength at higher redshifts. We furthermore use our measured clustering strengths, combined with models from Mo & White (2002), to determine the average total masses of the dark matter haloes hosting these galaxies. We conclude that for all galaxies in our sample the stellar-mass-to-total-mass ratio is always lower than the universal baryonic mass fraction. Using our results, and a compilation from the literature, we furthermore show that there is a strong correlation between stellar-mass-to-total-mass ratio and derived halo masses for central galaxies, such that more massive haloes contain a lower fraction of their mass in the form of stars over our entire redshift range. For central galaxies in haloes with masses M(halo)>10^13M(sun) we find that this ratio is <0.02, much lower than the universal baryonic mass fraction. We show that the remaining baryonic mass is included partially in stars within satellite galaxies in these haloes, and as diffuse hot and warm gas. We also find that, at a fixed stellar mass, the stellar-to-total-mass ratio increases at lower redshifts. This suggests that galaxies at a fixed stellar mass form later in lower mass dark matter haloes, and earlier in massive haloes. We interpret this as a halo downsizing effect, however some of this evolution could be attributed to halo assembly bias.