X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 50FAB47643E for ; Fri, 2 May 2003 18:42:45 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id B4E90476435 for ; Fri, 2 May 2003 18:42:44 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 16BF9D646; Fri, 2 May 2003 15:42:47 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 0C6DA5C0B; Fri, 2 May 2003 15:42:47 -0700 (PDT) Date: Fri, 2 May 2003 15:42:46 -0700 (PDT) From: Stephan Szabo To: Katka a Daniel Dunajsky Cc: Subject: Re: How to increase precision? In-Reply-To: Message-ID: <20030502153816.U77106-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-16.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/38 X-Sequence-Number: 13203 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.