Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8Ugq-0006SK-A9 for pgsql-general@arkaria.postgresql.org; Thu, 12 Sep 2019 19:23:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8Ugo-0005co-Tr for pgsql-general@arkaria.postgresql.org; Thu, 12 Sep 2019 19:23:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8Ugo-0005cd-KF for pgsql-general@lists.postgresql.org; Thu, 12 Sep 2019 19:23:34 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8Ugl-0000Mv-TC for pgsql-general@lists.postgresql.org; Thu, 12 Sep 2019 19:23:33 +0000 Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id 46Tpb52skPz165S for ; Thu, 12 Sep 2019 15:23:29 -0400 (EDT) Received: by panix2.panix.com (Postfix, from userid 17622) id 46Tpb51QfBz1ZVM; Thu, 12 Sep 2019 15:23:29 -0400 (EDT) Date: Thu, 12 Sep 2019 15:23:29 -0400 From: stan To: pgsql-general@lists.postgresql.org Subject: Referncing a calculated column in a select? Message-ID: <20190912192329.GA21150@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Editor: gVim User-Agent: Mutt/1.12.1 (2019-06-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I am creating some views, that have columns with fairly complex calculations in them. The I want to do further calculations using the result of this calculation. Right now, I am just duplicating the first calculation in the select fro the 2nd calculated column. There must be a batter way to do this, right? -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin