functiuon that returns array with distinct elements postgres code example
Example 1: postgresql make each element in array distinct
SELECT ARRAY(SELECT DISTINCT unnest(t_column)) FROM t_name;
Example 2: array aggre distinct postgres
SELECT ARRAY(SELECT DISTINCT e FROM unnest(ARRAY[a,b,c,d]) AS a(e))
FROM ( VALUES
('foo', 'bar', 'foo', 'baz' )
) AS t(a,b,c,d);