pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: josh@agliodbs.com
Cc: pgsql-sql@postgresql.org
Subject: Re: BOOLEAN question
Date: Tue, 29 Oct 2002 13:27:34 -0500
Message-ID: <22789.1035916054@sss.pgh.pa.us> (raw)
In-Reply-To: <200210281706.39015.josh@agliodbs.com>
References: <200210281706.39015.josh@agliodbs.com>

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.

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



view thread (10+ messages)  latest in thread

Message-ID: <22789.1035916054@sss.pgh.pa.us>
Permalink:  ../22789.1035916054@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22789.1035916054@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, josh@agliodbs.com
  Subject: Re: BOOLEAN question
  In-Reply-To: <22789.1035916054@sss.pgh.pa.us>

* 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