Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA13033 for ; Mon, 12 Jul 1999 12:58:22 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id MAA20536; Mon, 12 Jul 1999 12:57:19 -0400 (EDT) To: Thomas Good cc: "PostgreSQL::SQL List" Subject: Re: [SQL] calculating percentages In-reply-to: Your message of Mon, 12 Jul 1999 10:50:27 -0400 (EDT) Date: Mon, 12 Jul 1999 12:57:19 -0400 Message-ID: <20534.931798639@sss.pgh.pa.us> From: Tom Lane Thomas Good writes: > On Mon, 12 Jul 1999, Tom Lane wrote: >> Pretty much just like that. What problem are you having? > The divison rtns 0, which multiplied by 100, rtns 0. If your data is stored as int fields, then you'd get integer division, which sounds like what you're getting. You want a floating-point division, which you'd get by promoting to float: SELECT (current_value::float8/target::float8) * 100; regards, tom lane