Re: BOOLEAN question
| От | Tom Lane |
|---|---|
| Тема | Re: BOOLEAN question |
| Дата | |
| Msg-id | 22789.1035916054@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | BOOLEAN question (Josh Berkus <josh@agliodbs.com>) |
| Ответы |
Re: BOOLEAN question
|
| Список | pgsql-sql |
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.
PerhapsSELECT true = ANY (SELECT boolcol FROM ...);
orSELECT 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
В списке pgsql-sql по дате отправления: