Ok array_agg = naturalの最初の値なら、結果を排除する必要があるクエリを取得します。where句でaggregateを使用できない場合、結果を取得する方法
select
visitor_id,
array_agg(code
order by session_start) codes_array
from mark_conversion_sessions
where conv_visit_num2 < 2
and max_conv = 1
and (array_agg(code
order by session_start))[1] != 'natural'
group by visitor_id
しかし、私はこれを実行すると、私はエラーを取得する:
ERROR: aggregate functions are not allowed in WHERE
LINE 31: and (array_agg(code
だから私は、WHERE句でそのARRAY_AGGを参照することができます方法はありますか?
あなたは
使用 'having' https://www.postgresql.org/docs/current/static/queries- table-expressions.html#QUERIES-GROUP –
group byとclauseを使用してみます。 http://www.dofactory.com/sql/having – Nidhi257
フィルタの行をフィルタリングするグループです。 – Mihai