Josh Berkus <josh(at)agliodbs(dot)com> writes:
> Odd question: I have a query that returns a set of none to several rows. One
> column in these rows is BOOLEAN. I want the query to return:
> 1) TRUE if *any* of the BOOLEAN values is TRUE;
> 2) FALSE if *all* of the BOOLEAN values are FALSE;
> 3) FALSE or NULL if no rows are returned.
Perhaps
SELECT true = ANY (SELECT boolcol FROM ...);
or
SELECT true IN (SELECT boolcol FROM ...);
Which is not to say that MAX(bool) might not be a nicer solution;
but you can definitely do it with SQL-spec constructs.
regards, tom lane