PostgreSQL: Query DB for rows containing integer[] > or < than specified value I have a table which stores historical temperatures for the past 5 days stored in an integer[] column based on city. The question is: How can I query for entries which have a value great than or less than a specified value? Here's an example table:

+=========+==================+
| city    | temps            |
+=========+==================+
| Seattle | {65,72,63,56,72} |
+---------+------------------+
| Miami   | {83,75,69,72,79} |
+---------+------------------+


Let's say I want to query for cities which have experienced a temp higher than 80. In this example only Miami has experienced temps higher than 80, so only that row should be returned. I've tried a few queries with no success, looked into intarray, but that doesn't seem to solve my problem either. Thanks much!

I'm running PostgreSQL 9.1
Assuming your table is named readings:

Find cities where at least one temperature is bigger than 80:

select *
from readings r
where exists (select 1 
              from unnest(r.temps) i
              where i &gt; 80)


Find cities where all temperatures are bigger than 68:

select *
from readings r
where 68 &lt; all (select i
                from unnest(r.temps) i)