I have the following table named jobs:
id PK Serial
model String
model_id UNSIGNED Integer
status String
created_at timestamp
prosessed_at timestamp
And foreach model Id I record each status in an array:
select
model_id,
model,
array_agg(id) as jobs,
array_agg(statuses) as statuses
from jobs
group by model,model_id
And I use that as a subquery in order to detect any malfucntion in prosessed jobs:
select
*
from (
select
model_id,
model
array_agg(id) as jobs,
array_agg(statuses) as statuses
from jobs
group by model,model_id
) as jobs
where
'aborted' in statuses
and
'pending' not in statuses
and
'failed' not in statuses
and
'processed' not in statuses;
But in the following line:
'aborted' in statuses
Has some sort syntax error:
SQL Error [42601]: ERROR: syntax error at or near "statuses"
Position: 312
Do you have any idea why?