From: Michael Fuhr <mike@fuhr.org>
To: operationsengineer1@yahoo.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Advanced Query
Date: Fri, 2 Jun 2006 11:43:25 -0600
Message-ID: <20060602174325.GA2073@winnie.fuhr.org> (raw)
In-Reply-To: <20060602170901.75422.qmail@web33308.mail.mud.yahoo.com>
References: <20060602000051.GA12215@winnie.fuhr.org>
<20060602170901.75422.qmail@web33308.mail.mud.yahoo.com>
On Fri, Jun 02, 2006 at 10:09:01AM -0700, operationsengineer1@yahoo.com wrote:
> Michael, my derivative of your query example works
> great - thank you!
>
> i think i understand everything except why multiplying
> by 1.0 is necessary. when i take it out, my expected
> result, 0.50000000000..., turns into 0 - so i assume
> it has to do with formatting the result.
Integer division yields integers, so 1 / 2 = 0 whereas 1.0 / 2.0 = 0.5.
The expression therefore needs something to force a non-integer result.
Multiplying by 1.0 (or 100.0) is one way; using 1.0 and 0.0 in the CASE
expression is another; casting one of the operands to numeric or one of
the floating-point types is yet another.
--
Michael Fuhr
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: mike@fuhr.org, operationsengineer1@yahoo.com
Subject: Re: Advanced Query
In-Reply-To: <20060602174325.GA2073@winnie.fuhr.org>
* 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