or function

Поиск
Список
Период
Сортировка
От A. R. Van Hook
Тема or function
Дата
Msg-id 4596A525.9050008@lake-lotawana.mo.us
обсуждение исходный текст
Ответы Re: or function  (chester c young <chestercyoung@yahoo.com>)
Re: or function  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
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
seems to work ok when the value is 0 but I get the wrong value is 
i.count in not zero
stid | count | tot |   ldate    | pkcnt | status | cost
------+-------+-----+------------+-------+--------+------2995 |    12 |  44 | 12/18/2006 |    32 | Active | 3.60
qs "select sum(i.count * s.cost) from inventory i,stock s, stockkey k 
where i.stid=s.stid and i.status='Active' and s.ctype = k.cd and k.value 
= 'Other' and s.ssp = 'Stock'" sum
-------43.20
qs "select sum((1|i.count) * s.cost) from inventory i,stock s, stockkey k
where i.stid=s.stid and i.status='Active' and s.ctype = k.cd and k.value 
= 'Other' and s.ssp = 'Stock'" sum
-------46.80
43.20 <> 46.80
Thanks


-- 
Arthur R. Van Hook     Mayor 
The City of Lake Lotawana

hook@lake-lotawana.mo.us

(816) 578-4704 - Home
(816) 578-4215 - City
(816) 564-0769 - Cell



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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: domains and serial
Следующее
От: chester c young
Дата:
Сообщение: Re: or function