AMC: user_id is not allowed in the final SELECT

Columns with the very high threshold such as user_id can never appear in the output, only in intermediate steps or as COUNT or COUNT DISTINCT.

Symptom

A query that returns user_id in its last SELECT cannot run. Amazon describes the rule but does not print a fixed message text.

Cause

With the very high threshold no aggregation level would release the column: the output would expose the data of a single user.

Fix

  1. Only count user_id: COUNT(DISTINCT user_id) for reached users.
  2. Use user_id in a CTE for joins or frequencies and output only aggregated values in the final SELECT.
  3. For audiences use an audience query, where user_id is the intended output (audience recipes).

The cause follows the Amazon documentation. Some of the fix steps are our own judgement and do not replace asking Amazon support.

Source: AMC data aggregation thresholds (retrieved 2026-10-09)

See also: Schema reference with aggregation thresholds · All AMC errors