>
> How to remove duplicated values in an array and maintain the order?
>
> select array_agg(unnest) filter (where row_number = 1) from (select
unnest, ordinality, row_number() over(partition by unnest order by
ordinality) from (select * from
unnest('{7,7,5,6,2,2,3,8,5,4,5}'::integer[]) with ordinality) x order by
ordinality) x
{7,5,6,2,3,8,4}
regards
Marcos