From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: BOOLEAN question
Date: Mon, 28 Oct 2002 17:26:24 -0800 (PST)
Message-ID: <20021028172506.G86039-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <200210281706.39015.josh@agliodbs.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, josh@agliodbs.com
Subject: Re: BOOLEAN question
In-Reply-To: <20021028172506.G86039-100000@megazone23.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox