I have a table which is a log of mapping events for some integer id values. I am looking for a single sql query that can produce a new table with the latest resolved mapping