Write a SQL query using window functions to identify duplicate records and retain only the most recent entry based on a timestamp.