Terry Windwalker
Terry Windwalker

Reputation: 1888

How to Check if PostgreSQL Array Contains Value greater than a Value

Let's say I have several records with a column in type int[], and I want to find all the records containing at least one value greater than 200 in the array. How should I achieve that?

Sample data:

array
-------------
{18}
{489}
{218, 333, 100}
{23, 44, 102}

I would need to locate the second and third rows.

Upvotes: 1

Views: 1294

Answers (1)

Saya
Saya

Reputation: 353

SELECT * FROM table1 WHERE 200 < ANY(arr);

Upvotes: 5

Related Questions