创建自定义函数:
CREATE OR REPLACE FUNCTION "public"."array_distinct"(anyarray)
RETURNS "pg_catalog"."anyarray" AS $BODY$
SELECT ARRAY(SELECT DISTINCT unnest($1));
$BODY$
LANGUAGE sql VOLATILE
COST 100;
测试:
create table test (contentids integer[]);
insert into test values ({1,1,1,2,2,3,3,4});

select * from test;
select array_distinct ( contentids:: VARCHAR [] ) from test;

1427

被折叠的 条评论
为什么被折叠?



