I have broken my mind here to build a SQL, maybe someone can help me.
I'm trying to write a report to collect the relationship of notes that were eventually deleted.
The user registers an nf in the system that has the initial status "related", but in some cases it needs to delete this nf that changes from "related" status to "deleted", and does another, a new record is made to that same nf, with different id, however with the number of nf equal to previous but now with the status "related".
Finally, I wanted a sql query that is considered to be the last record of an nf that has "deleted" status.
For example, I have the following query:
SELECT id, nf, status, date FROM documentos
The statement returns the following records:
Asitshouldbe,fromtheaboveresultIwanttoknowonlythelastrecordofagivennfwhenitis"deleted" status.
I'm using Mysql to do the query.