user5128 Published in September 19, 2018, 11:09 am
I'm joining two tables, tblAccount and tblInvoice. TblAccount has multiple invoices related to each account. I'm trying to query the TotalSavings amount based on the oldest InvoiceDate and if there are two amount values on the same date then I need to sum of those two amounts. I thought I was doing this correct but the below code doesn't give me the desired output.
MIN(TI.InvoiceDate) AS InvoiceDate,
FROM tblAccount AS TA
LEFT JOIN tblInvoice AS TI
TI.InvoiceDate IS NOT NULL
GROUP BY TA.AccountID, TI.TotalSavings
ORDER BY TA.AccountID