Home > Software engineering >  How to Check if PostgreSQL Array Contains Value greater than a Value
How to Check if PostgreSQL Array Contains Value greater than a Value

Time:09-02

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.

CodePudding user response:

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