X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AB3E3D70B5 for ; Mon, 22 Aug 2005 16:54:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46241-10 for ; Mon, 22 Aug 2005 19:54:04 +0000 (GMT) Received: from TWMAIL.ESNCC.COM (static-66-173-159-28.t1.cavtel.net [66.173.159.28]) by svr1.postgresql.org (Postfix) with ESMTP id 6466CD7021 for ; Mon, 22 Aug 2005 16:54:00 -0300 (ADT) Received: from spawar2i8uvlb9 ([150.125.117.63]) by TWMAIL.ESNCC.COM with Microsoft SMTPSVC(5.0.2195.6713); Mon, 22 Aug 2005 15:54:01 -0400 From: "Lane Van Ingen" To: Subject: Why Doesn't SQL This Expression Work? Date: Mon, 22 Aug 2005 15:50:37 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 Importance: Normal X-OriginalArrivalTime: 22 Aug 2005 19:54:01.0696 (UTC) FILETIME=[3E298600:01C5A753] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.077 required=5 tests=[AWL=0.027, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/190 X-Sequence-Number: 22418 Hi, am trying to do a simple computation on two views, but for some reason the current_util_in computation always returns zero. All fields being used are integer. select a.if_id, a.in_count, a.time_incr, b.speed, ((a.time_incr * b.speed) / 8) as possible_bytes, (a.in_count / ((a.time_incr * b.speed) / 8) * 100) AS current_util_in, from if_history_view1 a, speed_history_view1 b where a.if_id = b.if_id and a.if_id = 2; The inner computation (a.time_incr * b.speed / 8) evaluated properly to 7675200. Add the "in_count divide operation", and the result is zero. The result expected is a percentage, and should compute to 7.68 (8 as an integer), when multiplied by 100. What is wrong here? Here is the result: Row if_id in_count time_incr speed possible_bytes current_util_in 1 2 589824 240 255840 7675200 0