X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 08DE411F6B6E for ; Sat, 1 Apr 2006 02:10:04 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84199-05 for ; Sat, 1 Apr 2006 02:10:01 -0400 (AST) X-Greylist: delayed 00:06:40.403405 by SQLgrey- Received: from hurricane.stormweb.net (hurricane.stormweb.net [65.39.129.23]) by postgresql.org (Postfix) with ESMTP id 4C24911F6617 for ; Sat, 1 Apr 2006 02:10:00 -0400 (AST) Received: (qmail 31385 invoked from network); 1 Apr 2006 01:03:18 -0500 Received: from localhost (127.0.0.1) by localhost with SMTP; 1 Apr 2006 01:03:18 -0500 Received: from 24.84.59.1 ([24.84.59.1]) by webmail.weaktight.com (Horde MIME library) with HTTP for ; Sat, 01 Apr 2006 01:03:17 -0500 Message-ID: <20060401010317.tbza82opw0c0ccg0@webmail.weaktight.com> Date: Sat, 01 Apr 2006 01:03:17 -0500 From: vince@weaktight.com To: pgsql-sql@postgresql.org Subject: query; check for zero and floats MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.0.3) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.55 required=5 tests=[NO_REAL_NAME=0.55] X-Spam-Score: 0.55 X-Spam-Level: X-Archive-Number: 200604/1 X-Sequence-Number: 24810 I'm trying to do a simple query and I'm not sure how to get it to work: SELECT SUM(x0 + y0 + z0) / SUM(x2 + y2) AS A1, SUM(x1 + y1 + z1) / SUM(x3 + y3) AS A2 FROM test Problems: 1. All variables are integers. When it does the division, it returns an integer, but I want a float. (I've tried numerous things to no avail) 2. If SUM(x2 + y2) == 0; there is a divide by zero error. How do I check and pass on zeroes? Thanks, Vince.