I am trying to figure out how to get this query to return an EFT Amount also the Sum of the Direct Deposit Amounts. Sometimes there are no direct deposit Amounts, So i need to use Outer Joins. I almost have it figured out, but im getting an extra row with all of the Direct Deposits in the data base sum'd up. Here is my SQL and the results
The results are correct except for the first record, I need help avoiding that record any suggestions would be appreciated.
Code:
select Customers.CustomerId,Customers.Description as Customer,EFT.Amount as EFT,sum(Checks.Amount) as DirectDeposit,'Note' as Note,EFT.EFTId,ACHBATCHS.ACHBatchId as ACHId from ToolCheckBatches full outer join AchBatchs on AchBatchs.ToolCheckBatchId = ToolCheckBatches.ToolCheckBatchId full outer join AchBatchItems on AchBatchItems.AchBatchId = AchBatchs.AchBatchId inner join Invoices on Invoices.InvoiceId = ToolCheckBatches.InvoiceId full outer join EFT on EFT.InvoiceId = Invoices.InvoiceId inner join Customers on Customers.CustomerId = ToolCheckBatches.CustomerId full outer join ToolChecks on ToolChecks.ToolCheckId=AchBatchItems.ToolCheckId full outer join Checks on Checks.CheckId=ToolChecks.CheckId group by Customers.CustomerId,Customers.Description,EFT.Amount,EFT.EFTId,AchBatchs.AchBatchId,ToolCheckBatches.ToolCheckBatchId
NULL NULL NULL 7099.5400 Note NULL NULL
2 Accurate Auto Body 1007.82000 NULL Note 22 NULL
5 Especially Imports, Inc. 659.58000 588.6200 Note 21 24
The results are correct except for the first record, I need help avoiding that record any suggestions would be appreciated.