  We present the mean spectral energy distribution (SED) of a sample of
optically selected quasars (QSOs) at redshifts of $1 \le z \le 5$. To derive
it, we exploit photometric information from SDSS, UKIDSS, and WISE surveys in
combination with a stacking analysis of \textit{Herschel}, \textit{AKARI}, and
\textit{Planck} maps at the location of the QSOs. The near-UV and optical parts
of the reconstructed mean rest-frame SED are similar to those found in other
studies. However, the SED shows an excess at 1-2 $\mu$m (when compared to the
aforementioned SEDs normalized in the near-UV) and a prominent bump around 4-6
$\mu$m, followed by a decrease out to $\sim 20 \,\mu$m and a subsequent far-IR
bump. From the fitted SEDs we estimate the average active galactic nuclei (AGN)
luminosity $L_{\rm AGN}$ and star formation rate (SFR) as function of cosmic
time, finding typical $L_{\rm AGN} \sim 10^{46} - 10^{47}$ erg/s and SFR $\sim
50 - 1000\, M_{\odot}/$yr. We develop mid-IR based criteria to split the QSO
sample, finding that these allow us to move along the average relationship in
the SFR vs. $L_{\rm AGN}$ diagram toward increasing AGN luminosities. When
interpreted in the context of the in-situ coevolution scenario presented by
Lapi et al. 2014, our results suggest that the detection in the far-IR band is
an effective criterion to select objects where the star formation is on the
verge of being affected by energy/momentum feedback from the central AGN.
