I’m getting duplicate account numbers when I user an inner join with transaction table. How do limit it so I do not see duplicate account numbers.
SELECT A01_AccountMaster.AccountNumber, A01_AccountMaster.FamilyMemberType,
A01_AccountMaster.AccountType, A01_AccountMaster.FamilyId,
A01_AccountMaster.Title, A01_AccountMaster.FirstName,
A01_AccountMaster.MiddleName, A01_AccountMaster.LastName,
A01_AccountMaster.Suffix, A01_AccountMaster.OrganizationName,
A01_AccountMaster.Status,
T01_TransactionMaster.Date,
T01_TransactionMaster.AccountNumber AS T01_Accountnumber
FROM A01_AccountMaster
INNER JOIN T01_TransactionMaster
ON A01_AccountMaster.AccountNumber = T01_TransactionMaster.AccountNumber
WHERE (A01_AccountMaster.Title = 'The')
AND (T01_TransactionMaster.Date between '01/01/2010' and '09/12/2012')
ORDER BY AccountNumber;
My suggestion would be to summarize the transaction table to get what you want from it.
To aggregate the data, use a query such as this:
Doing the aggregation at the subquery level simplifies the overall query, since you don’t have to do a group by with lots of fields. Also, if you introduce more tables, aggregating at the subquery level can prevent problems caused by interactions between the records in the other tables.