Re: How to remove duplicates in an array and maintain the order? - Mailing list pgsql-sql

From Marcos Pegoraro
Subject Re: How to remove duplicates in an array and maintain the order?
Date
Msg-id CAB-JLwY+FKxi-SHM_HQXgYO6uxJu2bb1qgUqjNQyQBgnS9DPhQ@mail.gmail.com
Whole thread Raw
In response to How to remove duplicates in an array and maintain the order?  (Shaozhong SHI <shishaozhong@gmail.com>)
List pgsql-sql
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 

pgsql-sql by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: How to remove duplicates in an array and maintain the order?
Next
From: Thomas Kellerer
Date:
Subject: Re: How to remove duplicates in an array and maintain the order?