select uuid from(select *,row_number() over(partition by productid order by time_stamp desc)rn from "automation".data)t where rn=1