0

There is a json_agg resulting in [10,20] or [null]. I want to filter all rows with [null] in the column. How is it possible to achieve this?

2 Answers 2

1

Sounds like a simple WHERE condition:

WHERE jsoncol::text = '[null]'
Sign up to request clarification or add additional context in comments.

3 Comments

Then i get this error: ERROR: operator does not exist: json = json LINE 78: ) x WHERE x.geometry = '[null]'::json ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. SQL state: 42883 Character: 3910
@Dalitos: you will need to use jsonb for that (on both sides)
Sorry, I have fixed the answer.
0

i found this solution: jsoncol ->>0 IS Null

3 Comments

That would also be true for a JSON like [null,42,"x"].
hm, do you have another solution?
Yes, see my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.