Aims. It is important to know the binary mass-ratio distribution to better understand the evolution of stars in binary systems and to constrain their formation. However, in most cases, that is, for single-lined spectroscopic binaries, the mass ratio cannot be measured directly, but can only be derived as the convolution of a function that depends on the mass ratio and on the unknown inclination angle of the orbit on the plane of the sky. Methods. We extend our previous method for deconvolving this inverse problem by obtaining the cumulative distribution function (CDF) for the mass-ratio distribution as an integral. Results. After a suitable transformation of variables, this problem becomes the same as the problem of rotational velocities vsini, allowing a close analytic formulation for the CDF. We here apply our method to two real datasets: a sample of Am star binary systems, and a sample of massive spectroscopic binaries in the Cyg OB2 association. Conclusions. We are able to reproduce previous results for the sample of Am stars. In addition, the mass-ratio distribution of massive stars shows an excess of systems with a low mass ratio, in contrast to what was claimed elsewhere. Our method proves to be very reliable and deconvolves the distribution from a sample in one single step.