I’m having an issue with a query in a system where objects can have multiple situations recorded in a history table (historico_situacao). The problem is that when pulling a report, I’m getting duplicate results due to minor time differences in the insertion of records. Even after using the DISTINCT clause, the registration date continues to be duplicated, affecting the accuracy of the generated report.
I would like to know if anyone could help me find a solution to retrieve only the latest change of a particular situation for an object, without the registration date being duplicated. Unfortunately, my access to the system is limited, and I cannot make direct changes to it. I appreciate any guidance or suggestions that can help resolve this issue.
PS: I apologize if English is not easy to understand.