create table test
(
id bigserial primary key,
price_id integer not null,
value integer not null,
time_action timestamp with time zone
)
select distinct price_id, (select value from test t2 where t1.price_id=t2.price_id order by time_action desc limit 1) from test t1
select distinct on (price_id), price_id,value from tablename order by price_id, time_action desc
select price_id, value from prices as t1 lateral (select value from test t2 where t1.id=t2.price_id order by time_action desc limit 1) on true;