From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Katka a Daniel Dunajsky <daniel_katka@hotmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to increase precision?
Date: Fri, 2 May 2003 15:42:46 -0700 (PDT)
Message-ID: <20030502153816.U77106-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <Law12-F72YKpDS7hx2700007b3c@hotmail.com>
On Fri, 2 May 2003, Katka a Daniel Dunajsky wrote:
> this is a newbie question:
>
> How to increase the precision of calculations in posgresql?
>
> When I run this query:
>
> select 5/2;
>
> I get:
>
> ?column?
> --------
> 2
>
> It should be 2.5 shouldn't it?
It's doing integer division since both arguments are integers. You'll need
to make one of them something like float, double or numeric.
For example, queries like:
select 5./2;
select 5/cast(2 as float);
etc... don't do integer division because one of
the arguments isn't typed as an integer type.
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: sszabo@megazone23.bigpanda.com, daniel_katka@hotmail.com
Subject: Re: How to increase precision?
In-Reply-To: <20030502153816.U77106-100000@megazone23.bigpanda.com>
* 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