GM
select Время, max(Скорость), max(Расход) from (select to_timestamp((d.source_time - 116444736000000000)::float / 10000000 ) as Время,
case when d.archive_itemid = 18 then Round( d.value::numeric , 2) end as Скорость,
case when d.archive_itemid = 17 then Round( d.value::numeric , 2) end as Расход
from public.data_raw d where d.status_code = 0 and layer =0 AND (d.archive_itemid = 18 OR d.archive_itemid = 17 ) as tbl group by Время