Context. Halo occupation distribution (HOD) is a powerful statistic that allows the study of several aspects of the matter distribution in the Universe, such as evaluating semi-analytic models of galaxy formation or imposing constraints on cosmological models. Consequently, it is important to have a reliable method for estimating this statistic, taking full advantage of the available information on current and future galaxy surveys. Aims. The main goal of this project is to combine photometric and spectroscopic information using a discount method of background galaxies in order to extend the range of absolute magnitudes and to increase the upper limit of masses in which the HOD is estimated. We also evaluate the proposed method and apply it to estimating the HOD on the Sloan Digital Sky Survey Data Release 7 (SDSS DR7) galaxy survey. Methods. We propose the background subtraction technique to mel information provided by spectroscopic galaxy groups and photometric survey of galaxies. To evaluate the feasibility of the method, we implement the proposed technique on a mock catalogue built from a semi-analytic model of galaxy formation. Furthermore, we apply the method to the SDSS DR7 using a galaxy group catalogue taken from spectroscopic version and the corresponding photometric galaxy survey. Results. We demonstrated the validity of the method using the mock catalogue.We applied this technique to obtain the SDSS DR7 HOD in absolute magnitudes ranging from $M=-21.5$ to $M=-16.0$ and masses up to $\simeq 10^{15} M_{\odot}$ throughout this range. On the brighter extreme, we found that our results are in excellent agreement with those obtained in previous works.