X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DB715475F5F for ; Thu, 27 Feb 2003 12:28:28 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 79188-02 for ; Thu, 27 Feb 2003 12:28:09 -0500 (EST) Received: from mast-dc0-sm06.private.ntl.com (cabletel1.cableol.net [194.168.3.4]) by postgresql.org (Postfix) with ESMTP id 92AC9475CB1 for ; Thu, 27 Feb 2003 11:59:29 -0500 (EST) Received: from mast-dc0-se03.private.ntl.com (unverified) by mast-dc0-sm06.private.ntl.com (Content Technologies SMTPRS 4.2.10) with ESMTP id for ; Thu, 27 Feb 2003 16:59:33 +0000 Received: by mast-dc0-se03.private.ntl.com with Internet Mail Service (5.5.2653.19) id ; Thu, 27 Feb 2003 16:59:33 -0000 Message-ID: <685AD5FCEB6BD5119A3A0008C7DB50510515D04A@MAST-WI0-SE01> From: "Mark Connelly@South Central" To: "'pgsql-sql@postgresql.org'" Subject: using Avg() Date: Thu, 27 Feb 2003 16:59:26 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/23 X-Sequence-Number: 12063 I have a table with a column named SwErr (Switch Error) with int values date with datetime values and SwID with char(3) I am trying to get a subset back where the folowing is true select the avg(SwErr) for the last 30 days where SwId = 'XX1' Select the value of todays value of SwErr where SwId = 'XX1' if todays value of SwErr is greater than 4 times the SwErr Average return in the value TIA Mark Connelly The contents of this email and any attachments are sent for the personal attention of the addressee(s) only and may be confidential. If you are not the intended addressee, any use, disclosure or copying of this email and any attachments is unauthorised - please notify the sender by return and delete the message. Any representations or commitments expressed in this email are subject to contract. ntl Group Limited