I have a Presto table assume it has [id, name, update_time] columns and data
(1, Amy, 2018-08-01),
(1, Amy, 2018-08-02),
(1, Amyyyyyyy, 2018-08-03),
(2, Bob, 2018-08-01)
Now, I want to execute a sql and the result will be
(1, Amyyyyyyy, 2018-08-03),
(2, Bob, 2018-08-01)
Currently, my best way to deduplicate in Presto is below.
select
t1.id,
t1.name,
t1.update_time
from table_name t1
join (select id, max(update_time) as update_time from table_name group by id) t2
on t1.id = t2.id and t1.update_time = t2.update_time
More information, clike deduplication in sql
Is there a better way to deduplicate in Presto?