I’m getting different results between each of these methods of getting data. The only one that gets accurate data is the SQL query. (In sql I am just changing the date parameter to a static date. That is the only difference.)
The issue seems to happen when grouping certain fields in the ARMovement table.
What I am attempting to do is create an AR query that reconciles for Central Collections by child company.
My BAQ seems to work just fine for previous months and begins to have issues starting in May. This is the first month that it appears to be missing records. (3 to be exact).
Any ideas?
select
[ARMovement].[Company] as [ARMovement_Company],
[Customer].[CustID] as [Customer_CustID],
[Customer].[Name] as [Customer_Name],
[InvcHead].[InvoiceNum] as [InvcHead_InvoiceNum],
[InvcHead].[CColChildCompany] as [InvcHead_CColChildCompany],
(SUM(ARMovement.TranAmt)) as [Calculated_InvoiceBal]
from Erp.ARMovement as ARMovement
left outer join Erp.InvcHead as InvcHead on
InvcHead.Company = ARMovement.Company
and InvcHead.InvoiceNum = ARMovement.InvoiceNum
and ( InvcHead.ApplyDate <= @Date and (InvcHead.OpenInvoice = 1 or InvcHead.ClosedDate > @Date ) )
inner join Erp.Customer as Customer on
(InvcHead.Company = Customer.Company
and InvcHead.CustNum = Customer.CustNum)
where (ARMovement.TranDate <= @Date)
group by [ARMovement].[Company],
[Customer].[CustID],
[Customer].[Name],
[InvcHead].[InvoiceNum],
[InvcHead].[CColChildCompany]