The two queries are different from each other, because the first returns only clients that have at least one match in the address table. The second returns all clients, even those who do not have a match, and AddressId- NULL.
Equivalent first request:
SELECT c.CustomerID, COUNT(a.AddressId) AS NumDuplicates
FROM Customers C LEFT JOIN
Addresses a
ON c.AddressID = a.AddressID
GROUP BY c.CustomerID
ORDER BY NumDuplicates DESC;
, . , . , . SQL Server . , , .