Here's an all-in-one solution:
Code:
SELECT A.col1 AS Name, Sum(A.col2) AS Installed, Sum(A.col3) AS Purchased
FROM (SELECT License.displayname AS col1, Count(License.displayname) AS col2, CLng(0) AS col3
FROM Installed INNER JOIN License ON Installed.product_name = License.productname
GROUP BY License.displayname, CLng(0)
UNION
SELECT License.displayname AS col1, CLng(0) AS col2, Sum(Purchases.quantity) AS col3
FROM Purchases INNER JOIN License ON Purchases.item_description = License.productname
GROUP BY License.displayname, CLng(0)
) AS A
GROUP BY A.col1;
Note the structure. There is an outer query acting on a result set called A and containing three columns: col1, col2 and col3.
SELECT A.col1 AS Name, Sum(A.col2) AS Installed, Sum(A.col3) AS Purchased FROM *** GROUP BY A.col1;
The inner query (*** in the above) is the union of the two intermediate queries in my previous post with the aliases suitably altered and with the result set named A.
OK, to complete Hilaire Belloc's advice: I have given you a three query solution that uses a linking of two intermediate queries; and an integrated solution that uses an inner union query. Actually the integrated solution could also use a linking but I thought the union was clearer.