SQL: Inner Join Query assist
Posted on 2014-01-09
I have two tables:
Products contains an ProductID, Product name as well as other descriptors. It can have multiple records for the same ID & Product Name.
Transactions contain a ProductID, category and various fields of information based on the sale of specific products.
I'm trying to query the Transactions and retrieve a count of transactions for a specific category along with the Product Name from the Products table.
The count is multiplying the number of records found in the Transaction table by the number of records in the Products table.
How can I correct this?
Select Distinct count(a.pProductID)
from TRANSACTION_TABLE a
INNER JOIN PRODUCTS B
ON A.PRODUCT_ID = B.PRODUCT_ID
GROUP BY B.PRODUCT_NAME