I am trying to create a statement like report for invoices, I have it so far that it displays the invoice and the amount due and also the payment if it has been paid, I have all this in a table with the invoice on 1 line and the payments on another with them grouped. What i really what to achieve is to have them ordered by date and for it to look like a statement.
Is this even possible does anyone have any ideas on what I could do to achieve this.
Below is my current SQL Select statement.
SELECT FilteredInvoice.accountidname, FilteredInvoice.createdon, FilteredInvoice.duedate, FilteredInvoice.invoicenumber, FilteredInvoice.statecodename,
FilteredInvoice.totalamount_base, FilteredMag_Payment.mag_paymentdate, FilteredMag_Payment.mag_amount_base, GETDATE() AS Today
FROM FilteredInvoice LEFT OUTER JOIN
FilteredAccount ON FilteredInvoice.accountid = FilteredAccount.accountid LEFT OUTER JOIN
FilteredMag_Payment ON FilteredInvoice.invoiceid = FilteredMag_Payment.mag_invoiceid
WHERE (FilteredInvoice.statecodename <> N'Canceled')
ORDER BY FilteredInvoice.createdon