This work presents results on quarkonium and heavy flavour production using data collected by the CMS experiment at the LHC in pp collisions during Run I. The emphasis is placed on the most recent measurements, including the S-wave cross sections up to transverse momenta exceeding 100 GeV, the polarizations of Ξ₯(nS) mesons as function of charged particle multiplicity as well as the study of Bc+β mesons decaying to J/ΟΟ+ and J/ΟΟ+Ο+Οβ. Moreover, preliminary dimuon mass distributions obtained with early Run II data collected at sβ= 13 TeV in 2015 are shown