私は、引数としてdistinctを持つarray_aggを使ったクエリを持っていますが、postgres 9.6では受け入れられません。array_agg postgres 9.4ではっきりとした作品ではありますが、postgresではありません9.6
create table numbers (id integer primary key, name varchar(10));
insert into numbers values(1,'one');
insert into numbers values(2,'two');
はpostgres 9.4
select array_agg(distinct(id)) from numbers;
array_agg
-----------
{1,2}
postgresの私は、この結果を得るために変更する必要がありますどのような9.6
ERROR: function array_agg(integer) is not unique
LINE 1: select array_agg(distinct(id)) from numbers;
^
HINT: Could not choose a best candidate function.
You might need to add explicit type casts.
:
は、私は問題を説明するために、このサンプルを作成しましたポストグル9.6?ありがとうございました。
は、これは私が機能をチェックし得るものです:
nspname | proname | proargtypes
------------+-----------+---------------------
pg_catalog | array_agg | [0:0]={anyarray}
public | array_agg | [0:0]={anyelement}
pg_catalog | array_agg | [0:0]={anynonarray
さて、私はpozsによってコメントに問題のおかげで見つけました。集計された関数のパブリック定義を削除し、それが機能しました。
問題は私が作業していたデータベース上にありました。サンプルがそれらのために働いていたという人がいましたので、私は新しいデータベースを作成しました。そして、唯一の変更は集合関数定義でした。
関連性はありませんが、「distinct」は** not **の機能です。 'distinct id'は' distinct(id) 'と同じです –
あなたの例は私にとっては9.6.2で動作します:https://i.imgur.com/PgaAkRD.png –
ありがとう、ありがとう gcc(Ubuntu 5.3.1-14ubuntu2)でコンパイルされたPostgreSQL 9.6.2 5.3.1 20160413,64ビット –