Context. The TOPoS project has the goal to find and analyse Turn-Off (TO) stars of extremely low metallicity. To select the targets for spectroscopic follow-up at high spectral resolution, we have relied on low-resolution spectra from the Sloan Digital Sky Survey. Aims. In this paper we use the metallicity estimates we have obtained from our analysis of the SDSS spectra to construct the metallicity distribution function (MDF) of the Milky Way, with special emphasis on its metal-weak tail. The goal is to provide the underlying distribution out of which the TOPoS sample was extracted. Methods. We make use of SDSS photometry, Gaia photometry and distance estimates derived from the Gaia parallaxes to derive a metallicity estimate for a large sample of over 24 million TO stars. This sample is used to derive the metallicity bias of the sample for which SDSS spectra are available. Results. We determined that the spectroscopic sample is strongly biased in favour of metal-poor stars, as intended. A comparison with the unbiased photometric sample allows to correct for the selection bias. We select a sub-sample of stars with reliable parallaxes for which we combine the SDSS radial velocities with Gaia proper motions and parallaxes to compute actions and orbital parameters in the Galactic potential. This allows us to characterize the stars dynamically, and in particular to select a sub-sample that belongs to the Gaia-Sausage-Enceladus (GSE) accretion event. We are thus able to provide also the MDF of GSE. Conclusions. The metal-weak tail derived in our study is very similar to that derived in the H3 survey and in the Hamburg/ESO Survey. This allows us to average the three MDFs and provide an error bar for each metallicity bin. Inasmuch the GSE structure is representative of the progenitor galaxy that collided with the Milky Way, that galaxy appears to be strongly deficient in metal-poor stars compared to the Milky Way, suggesting that the metal-weak tail of the latter has been largely formed by accretion of low mass galaxies rather than massive galaxies, such as the GSE progenitor.