I am extracting data from an access DB using vb6. I am trying to extract the last 5 transactions for every account a customer has. I can extract every transaction for every account a user has but need to cut it down. I am having to run two queries just now as transactions are held in two different tables i.e. current year and archived transactions. I have to run it on the archived one as some customers havent made 5 transactions in the one year for all their accounts. Can I combine them and extract the last 5 or do I have to keep them seperate.
The queries I have are -
INSERT INTO `Transactions` (credit_union_id, customer_id, account_id, transaction_detail, `timestamp`, amount) SELECT Account.credit_union_id, Account.customer_id, Account.account_id, Trantype_ID.tranname, Membertrans.Trandate, Membertrans.Tranvalue1 FROM Trantype_ID, Membertrans, Account WHERE Trantype_ID.trantype = Membertrans.Trantype AND Membertrans.Memberno = Account.customer_id AND Membertrans.Account = Account.account_id
INSERT INTO Transactions(credit_union_id, customer_id, account_id, transaction_detail, `timestamp`, amount) SELECT Account.credit_union_id, Account.customer_id, Account.account_id, Trantype_ID.tranname, Memberalltrans.Trandate, Memberalltrans.Tranvalue1 FROM Memberalltrans, Account, Trantype_ID WHERE Memberalltrans.Account = Account.account_id AND Memberalltrans.Memberno = Account.customer_id AND Memberalltrans.Trantype = Trantype_ID.trantype
Would appreciate some help in reducing the transactions to 5.
Transactions are timestamped.