# Help proving $\sum_{pq \leq x} \log p\log q \frac{\log x}{\log pq} = \sum_{pq \leq x} \log p\log q + O(x)$

I'm reading Selberg, A. (1949). An Elementary Proof of the Prime-Number Theorem After deriving his formula: $$\sum_{p \leq x} \log^2 p + \sum_{pq \leq x} \log p \log q = 2x\log x + O(x)$$ The author states that "By partial summation we get from (formula above)" to: $$\sum_{p \leq x} \log p + \sum_{pq \leq x} \frac{\log p \log q}{\log pq} = 2x + O(\frac{x}{\log x})$$ I don't understand how to derive this by partial sums but since I know that: $$\sum_{p \leq x} \log^2 p = \log x \sum_{p \leq x} \log p + O(x)$$ I figure that I need the equation in question $$\sum_{pq \leq x} \log p\log q \frac{\log x}{\log pq} = \sum_{pq \leq x} \log p\log q + O(x)$$ problem being that I am unable to prove this so please help. (Also if unclear note that $p$ and $q$ denote primes being not necessarily different)

If we define \begin{align} f(n) &= \begin{cases} (\log n)^2 &\text{if } n \text{ is prime}, \\ \quad 0 &\text{otherwise}, \end{cases} \\ g(n) &= \sum_{pq = n} \log p\log q\,, \end{align} and $h(n) = f(n) + g(n)$, the formula we start with is $$H(x) := \sum_{n \leqslant x} h(n) = 2x\log x + O(x)\,. \tag{\ast}$$ Using Abel's formula we obtain \begin{align} \sum_{p \leqslant x} \log p + \sum_{pq \leqslant x} \frac{\log p\log q}{\log (pq)} &= \sum_{2 \leqslant n \leqslant x} \frac{h(n)}{\log n} \\ &= \frac{H(x)}{\log x} + \int_2^x \frac{H(t)}{t(\log t)^2}\,dt \\ &= 2x + O\biggl(\frac{x}{\log x}\biggr) + 2\int_2^x \frac{dt}{\log t} + \int_2^x O\biggl(\frac{1}{(\log t)^2}\biggr)\,dt \\ &= 2x + 2\operatorname{Li}(x) + O\biggl(\frac{x}{\log x}\biggr) + O\biggl(\frac{x}{(\log x)^2}\biggr) \\ &= 2x + O\biggl(\frac{x}{\log x}\biggr)\,. \end{align} The same technique gives the results for the component parts, but without the prime number theorem we cannot yet explicitly state the asymptotics of each part. Using Chebyshev's result that $\vartheta(x) \in \Theta(x)$ we get \begin{align} F(x) &= \sum_{n \leqslant x} f(n) \\ &= \sum_{p \leqslant x} (\log p)\cdot (\log p) \\ &= \vartheta(x)\log x - \int_1^x \frac{\vartheta(t)}{t}\,dt \\ &= \vartheta(x)\log x + \int_1^x O(1)\,dt \\ &= \vartheta(x)\log x + O(x) \end{align} and, since $G(x) \in O(x\log x)$ by this and $(\ast)$, \begin{align} \sum_{n \leqslant x} \frac{g(n)}{\log n} &= \frac{G(x)}{\log x} + \int_2^x \frac{G(t)}{t(\log t)^2}\,dt \\ &= \frac{G(x)}{\log x} + O\biggl(\frac{x}{\log x}\biggr)\,, \end{align} which is indeed $$\sum_{pq\leqslant x} \log p\log q\frac{\log x}{\log (pq)} = \sum_{pq \leqslant x} \log p\log q + O(x)\,.$$