From: Tom Lane <tgl@sss.pgh.pa.us>
To: A. R. Van Hook <hook@lake-lotawana.mo.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: or function
Date: Sat, 30 Dec 2006 13:11:36 -0500
Message-ID: <13471.1167502296@sss.pgh.pa.us> (raw)
In-Reply-To: <4596A525.9050008@lake-lotawana.mo.us>
References: <4596A525.9050008@lake-lotawana.mo.us>
"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
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: tgl@sss.pgh.pa.us, hook@lake-lotawana.mo.us
Subject: Re: or function
In-Reply-To: <13471.1167502296@sss.pgh.pa.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