I have data from two spreadsheets where I need to compare the quantities of software installed and purchased. The common fields are prefix and client across the two spreadsheets, but there is no unique identifier.
I have created 3 tables. A Primary Key in Client (Client_ID) and foreign keys in Installed and Purchased. # Primary * Foreign
TABLES:-
Client - Client.Client_ID#, Client.Client
Installed - Installed.Client_ID*, Installed.Prefix, Installed.Publisher, Installed.Version,Installed.Amount
Purchased -Purchase.Client_ID*, Purchase.Prefix, Purchase.Status, Purchase.Qty
Part of the issue that I am having is that the most of the records/rows are list multiple times. E.g Product Y is recorded as 20 line items/ rows rather that Y Quantity 20.
I want to calculate the count (Installed.Amount) based on the prefix AND client_ID.
So far I can only calculate the count on the prefix and not client_ID. Is it possible to combine columns so the query will result the quantity of the Prefix and additional columns.
Query:-
SELECT Installed.Prefix, Count(Installed.Amount) AS PrefixQuantity
FROM Installed
GROUP BY Installed.Prefix;
BTW, I think you should use:
This will give correct results even if the Amount column has a value of more than 1.