Re: or function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: or function
Дата
Msg-id 13471.1167502296@sss.pgh.pa.us
обсуждение исходный текст
Ответ на or function  ("A. R. Van Hook" <hook@lake-lotawana.mo.us>)
Список pgsql-sql
"A. R. Van Hook" <hook@lake-lotawana.mo.us> writes:
> I have been trying to do an 'or' function such that if a field value is 
> zero then use 1 as a multiplier:
>  "select sum((1 | i.count) * s.cost) as COST

Bitwise OR will surely not do what you want.  I think the most effective
solution is probably CASE:

select sum(case when i.count = 0 then s.cost else i.count * s.cost end) ...
        regards, tom lane


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

Предыдущее
От: chester c young
Дата:
Сообщение: Re: or function
Следующее
От:
Дата:
Сообщение: [SQL NOTIFY Help] sending NOTIFY to the external program