Re: add, subtract bool type

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: add, subtract bool type
Дата
Msg-id Pine.LNX.4.30.0108221711230.679-100000@peter.localdomain
обсуждение исходный текст
Ответ на add, subtract bool type  (Jeff Davis <list-pgsql-general@dynworks.com>)
Список pgsql-general
Jeff Davis writes:

> I made some simple functions that create the operators + and - for any
> combination of int4's and bool's.
>
> The reasoning that propted this operator was that I wanted to use the
> following syntax in a query:
> SELECT *,((col_a == 'foo') + (col_b == 'bar')) as relevance WHERE
> relevance > 0;

You could also try

case when col_a = 'foo' then 1 else 0 end + case when col_b = 'bar' then 1
else 0 end

which is the usual way to "cast" booleans.

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter


В списке pgsql-general по дате отправления:

Предыдущее
От: "Paul C."
Дата:
Сообщение: FTI is really really slow; what am I doing wrong?
Следующее
От: "Mitch Vincent"
Дата:
Сообщение: Re: FTI is really really slow; what am I doing wrong?