I need split array by 2-pair portions, only nearby values.
For example I have following array:
select array[1,2,3,4,5]
{1,2}
{2,3}
{3,4}
{4,5}
select a
from (
select array[e, lead(e) over()] as a
from unnest(array[1,2,3,4,5]) u(e)
) a
where not exists (
select 1
from unnest(a) u (e)
where e is null
);
a
-------
{1,2}
{2,3}
{3,4}
{4,5}