SELECT
date_trunc('day', sub."timestamp") AS "day",
sub."data"
FROM (SELECT
"timestamp",
"data",
row_number() OVER ( PARTITION BY date_trunc('day', "timestamp")
ORDER BY "timestamp" DESC ) AS rownum
FROM "table") sub
WHERE sub.rownum = 1