pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A. R. Van Hook <hook@lake-lotawana.mo.us>
To: pgsql-sql@postgresql.org
Subject: or function
Date: Sat, 30 Dec 2006 11:43:01 -0600
Message-ID: <4596A525.9050008@lake-lotawana.mo.us> (raw)

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




view thread (3+ messages)  latest in thread

Message-ID: <4596A525.9050008@lake-lotawana.mo.us>
Permalink:  ../4596A525.9050008@lake-lotawana.mo.us/
Also on:    postgresql.org/message-id/4596A525.9050008@lake-lotawana.mo.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: hook@lake-lotawana.mo.us
  Subject: Re: or function
  In-Reply-To: <4596A525.9050008@lake-lotawana.mo.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox