I am using ARRAY_AGG
on a field with potentially NULL values and I then want to check the array later for any NULL entires. For example:
WITH test AS
(
SELECT 'A' AS call_id, NULL AS outcome
UNION ALL
SELECT 'A' AS call_id, 'success' AS outcome
)
SELECT *
FROM (
SELECT call_id, ARRAY_AGG(outcome) AS outcome
FROM test
GROUP BY call_id
) AS sub
WHERE outcome && ARRAY[NULL]
But the result of this query is no rows are returned. The ARRAY_AGG
will create one row with call_id
= 'A' and the outcome
array equal to {,'success'}. How do I check this array for NULL values?