Re: BOOLEAN question

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: BOOLEAN question
Date: 2002-10-29 01:26:24
Message-ID: 20021028172506.G86039-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-10-29 01:29:35 Re: BOOLEAN question
Previous Message Josh Berkus 2002-10-29 01:06:39 BOOLEAN question