X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 311C89FA220 for ; Fri, 2 Jun 2006 14:43:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 00801-02 for ; Fri, 2 Jun 2006 14:43:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 768909FA0E5 for ; Fri, 2 Jun 2006 14:43:31 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id k52HhQkN027691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 2 Jun 2006 11:43:28 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.6/8.13.6) with ESMTP id k52HhPHB002106; Fri, 2 Jun 2006 11:43:25 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.6/8.13.6/Submit) id k52HhPuZ002105; Fri, 2 Jun 2006 11:43:25 -0600 (MDT) (envelope-from mfuhr) Date: Fri, 2 Jun 2006 11:43:25 -0600 From: Michael Fuhr To: operationsengineer1@yahoo.com Cc: pgsql-sql@postgresql.org Subject: Re: Advanced Query Message-ID: <20060602174325.GA2073@winnie.fuhr.org> References: <20060602000051.GA12215@winnie.fuhr.org> <20060602170901.75422.qmail@web33308.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060602170901.75422.qmail@web33308.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/40 X-Sequence-Number: 25276 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