Re: [SQL] BOOLEAN question

2002-10-30 Thread Jean-Luc Lachance
Of course, I meant SELECT COALESCE( (SELECT true FROM ... WHERE ... AND boolcol LIMIT 1), FALSE); Jean-Luc Lachance wrote: > > Why not simply: > > SELECT COALESCE( (SELECT true FROM ... WHERE boolcol LIMIT 1), FALSE); > > JLL > > Josh Berkus wrote: > > > > Tom, > > > > > Perhaps > > >

Re: [SQL] BOOLEAN question

2002-10-30 Thread Jean-Luc Lachance
Why not simply: SELECT COALESCE( (SELECT true FROM ... WHERE boolcol LIMIT 1), FALSE); JLL Josh Berkus wrote: > > Tom, > > > Perhaps > > SELECT true = ANY (SELECT boolcol FROM ...); > > or > > SELECT true IN (SELECT boolcol FROM ...); > > > > Which is not to say that MAX(bool) migh

Re: [SQL] BOOLEAN question

2002-10-29 Thread Bruno Wolff III
On Tue, Oct 29, 2002 at 23:19:55 +0100, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > Josh Berkus writes: > > > I wrote a MAX(bool), what are the chances it would get added to the core? I > > don't see any good reason not to have one. > > One reason not to have one is that Boolean values are

Re: [SQL] BOOLEAN question

2002-10-29 Thread Peter Eisentraut
Josh Berkus writes: > I wrote a MAX(bool), what are the chances it would get added to the core? I > don't see any good reason not to have one. One reason not to have one is that Boolean values are not naturally ordered, so a maximum doesn't exist. (Yes, I know there are comparison operators de

Re: [SQL] BOOLEAN question

2002-10-29 Thread Josh Berkus
Tom, > 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. Based on some rough testing, SELECT true = A

Re: [SQL] BOOLEAN question

2002-10-29 Thread Tom Lane
Josh Berkus <[EMAIL PROTECTED]> 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

Re: [SQL] BOOLEAN question

2002-10-28 Thread Stephan Szabo
On Mon, 28 Oct 2002, Josh Berkus wrote: > Stephan, > > > 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 > > Good, I'm not just brain-dead. I did figure out another way to do it, but if > I wrote a MAX(

Re: [SQL] BOOLEAN question

2002-10-28 Thread Josh Berkus
Stephan, > 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 Good, I'm not just brain-dead. I did figure out another way to do it, but if I wrote a MAX(bool), what are the chances it would get added to the

Re: [SQL] BOOLEAN question

2002-10-28 Thread Stephan Szabo
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

[SQL] BOOLEAN question

2002-10-28 Thread Josh Berkus
Folks, 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 thoug