U kunt vaste aantallen rijen samenvoegen met row_number()
en rekenen:
select min(date),
(array_agg(bid order by seqnum asc))[1] as open,
(array_agg(bid order by seqnum desc))[1] as close,
min(bid) as min_bid, max(bid) as max_bid
from (select t.*, row_number() over (order by date) as seqnum
from ticks t
) t
group by floor((seqnum - 1) / 500);
Dit gebruikt "hack" om de open
. te krijgen en close
-- door arrays te gebruiken.