Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5A255476105 for ; Mon, 28 Oct 2002 20:26:22 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id E59AD476036 for ; Mon, 28 Oct 2002 20:26:21 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id EC647D60F; Mon, 28 Oct 2002 17:26:24 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id CDEAB5C04; Mon, 28 Oct 2002 17:26:24 -0800 (PST) Date: Mon, 28 Oct 2002 17:26:24 -0800 (PST) From: Stephan Szabo To: Josh Berkus Cc: Subject: Re: BOOLEAN question In-Reply-To: <200210281706.39015.josh@agliodbs.com> Message-ID: <20021028172506.G86039-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/385 X-Sequence-Number: 10102 On Mon, 28 Oct 2002, Josh Berkus wrote: > 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. > > I thought that I could do this through a MAX(boolean), but as it turns out, > MAX(boolean) has not been defined in the standard 7.2.3. distro. I could > define MAX(boolean), but I'm wondering if I'm missing something obvious. Well, you might be better off making a max(bool), but a not super-efficient version might be: max(case when col then 1 else 0 end)=1