Re: Boolean to integer conversion

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Boolean to integer conversion
Дата
Msg-id jkvi7i$a82$1@dough.gmane.org
обсуждение исходный текст
Ответ на Boolean to integer conversion  (JORGE MALDONADO <jorgemal1960@gmail.com>)
Список pgsql-novice
JORGE MALDONADO wrote on 28.03.2012 19:20:
> Is it possible to convert a boolean field to integer? (True = 1,
> False = 0)
>
> In the following example, "price" is a non-zero numeric field and
> "status" is a boolean field. So that, when "status=False" then
> "final_price=0.00" and when "status=True" then "final_price <>
> 0.00".
>
> SELECT (price * status) AS final_price
>
> I know that I can use a "CASE WHEN..." statement but, in this case,
> it is not the solution I am looking for.
>

SELECT (price * status::int) AS final_price


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

Предыдущее
От: JORGE MALDONADO
Дата:
Сообщение: Boolean to integer conversion
Следующее
От: Mephysto
Дата:
Сообщение: Re: Show stored function code