Statements are not designed to give a full customer transaction history. They usefully report unpaid (ie outstanding) Invoices, and help answer the questions, "Who owes money, how much, and when ?". if you need to have a customer transaction history, the code below might work. Hope you can improve it too. Alf Note. Replace the perl $variables with something valid
*SELECT transdate AS date, invnumber AS reference, amount*-1 FROM ar WHERE (ar.customer_id=(SELECT id FROM customer WHERE customernumber='$customer_number')) UNION ALL SELECT acc_trans.transdate AS date, 'Receipt' AS reference, acc_trans.amount AS amount FROM acc_trans, customer, ar WHERE (customer.customernumber=**'$customer_number'**) AND (customer.id=ar.customer_id) AND (ar.id=acc_trans.trans_id) AND (acc_trans.chart_id=(SELECT id FROM chart WHERE accno='$bank_account_code')) ORDER BY date *
_______________________________________________ SQL-Ledger mailing list [email protected] http://lists.ledger123.com/mailman/listinfo/sql-ledger
