I am working on a small credit/debt management tool.
I have a table that contains the main record for the debt: id, amount, client info, interest, paid back, etc
Then I also have a "history" table where all operations on a debt are stored: when it was first entered, when something is changed and so forth.
Debt table is as follows:
debt_id int(6) data_insertion timestamp debt_date date amount float(7,2) paidback float(7,2) customer_id varchar(6) agent_id int(4) PRIMARY_KEY(debt_id)
operation_id int(6) data timestamp amount float(7,2) customer_id varchar(6) debt_id int(6) optype tinyint(1) PRIMARY_KEY(operation_id)
How can I select the date of the most recent record in "history" for each "debt_id"?