Estimation of $\pi_2(x)=\#\{n\leq x:n=p_1p_2\}$, where $p_1$ and $p_2$ are two distinct primes Let $\pi_2(x)=\#\{n\leq x:n=p_1p_2\}$, where $p_1$ and $p_2$ are two distinct primes. I was told to prove that 
$$
\pi_2(x)=\sum_{p\leq \sqrt{x}}\pi\left ( \frac{x}{p} \right )+O\left ( \frac{x}{(\log x)^2} \right )\tag{1}
$$
using the hints $\pi_2(x)=\sum_{p_1\leq \sqrt{x}}\sum_{p_1< p_2\leq x/p_1} 1$ and $\pi(x)=O(x/\log x) $. 
The second hint comes from PNT. I tried to prove the first hint myself. Unfortunately I am not familiar with this kind of rewriting the summation signs. Suppose WLOG that $p_1<p_2$. Then $p_1^2<p_1p_2\leq x$, which implies that $p_1< \sqrt{x}$ and $p_1<p_2\leq x/p_1$. Looking at the hint, one index has $p_1\leq \sqrt{x}$ instead of $p_1<\sqrt{x}$. Is there something I misunderstand, or how do I fix this?
I see that $\sum_{p_1< p_2\leq x/p_1} 1=\pi(x/p_1)$, if I am not mistaken, but I do not know where the error term comes from.
 A: It doesn't matter whether we use the strict inequality $p_1 < \sqrt{x}$ or the non-strict $p_1 \leqslant \sqrt{x}$. If $x$ is not the square of a prime, then both inequalities give the same range of primes for the outer sum. If $x = p^2$ for a prime $p$, then the outer sum includes $p$ with the non-strict inequality, but not with the strict inequality. However, in that case we have $p = \frac{x}{p}$, and the range of the inner sum, $p < p_2 \leqslant \frac{x}{p}$ is empty, hence the inner sum is $0$. So both ways give the same sum.
We get the formula by grouping the $n \leqslant x$ that are the product of two different primes by their smaller prime factor. For fixed $p_1 \leqslant \sqrt{x}$, the map $q \mapsto p_1\cdot q$ is a bijection between the set of primes that are greater than $p_1$ and not greater than $\frac{x}{p_1}$ and the set $\{ n \leqslant x : n = p_1p_2, p_1 < p_2\}$, so there are precisely
$$\pi\biggl(\frac{x}{p_1}\biggr) - \pi(p_1)$$
non-square semiprimes not exceeding $x$ whose smaller prime factor is $p_1$. Since the smallest prime factor of a composite $n$ never exceeds $\sqrt{n}$, every semiprime not exceeding $x$ has a prime factor $\leqslant \sqrt{x}$. This gives the formula
$$\pi_2(x) = \sum_{p_1 \leqslant \sqrt{x}} \sum_{p_1 < p_2 \leqslant x/p_1} 1 = \sum_{p_1 \leqslant \sqrt{x}} \Biggl(\pi\biggl(\frac{x}{p_1}\biggr) - \pi(p_1)\Biggr).$$
The error term is then
$$- \sum_{p\leqslant \sqrt{x}}\pi(p),$$
and you can estimate that using the prime number theorem. [It's good to know that if $p$ is the $k$-th prime, then $\pi(p) = k$, so the sum is of the form $1 + 2 + \dotsc + m$.]
