Re: BOOLEAN question - Mailing list pgsql-sql

From Tom Lane
Subject Re: BOOLEAN question
Date
Msg-id 22789.1035916054@sss.pgh.pa.us
Whole thread Raw
In response to BOOLEAN question  (Josh Berkus <josh@agliodbs.com>)
Responses Re: BOOLEAN question
List pgsql-sql
Josh Berkus <josh@agliodbs.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.

PerhapsSELECT true = ANY (SELECT boolcol FROM ...);
orSELECT 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


pgsql-sql by date:

Previous
From: Philip Van Hoof
Date:
Subject: Creating Stored Procedures
Next
From: Stephan Szabo
Date:
Subject: Re: Creating Stored Procedures