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  ("Josh Berkus" <josh@agliodbs.com>)
Список 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 по дате отправления:

Предыдущее
От: Philip Van Hoof
Дата:
Сообщение: Creating Stored Procedures
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Creating Stored Procedures