Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1THuk1-0002y4-J9 for pgsql-sql@postgresql.org; Sat, 29 Sep 2012 10:57:49 +0000 Received: from mailout01.ims-firmen.de ([213.174.32.96]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1THujz-0003ox-SC for pgsql-sql@postgresql.org; Sat, 29 Sep 2012 10:57:49 +0000 Received: from mailin02.ims-firmen.de ([192.168.1.142]) by mailout01.ims-firmen.de with esmtp (envelope-from ) id 1THujz-0001vH-he; Sat, 29 Sep 2012 12:57:47 +0200 Received: from [213.174.32.192] (helo=oxweb02.ims-firmen.de) by mailin02.ims-firmen.de with esmtpsa (TLSv1:RC4-MD5:128) (envelope-from ) id 1THujz-0006Io-4l; Sat, 29 Sep 2012 12:57:47 +0200 Date: Sat, 29 Sep 2012 12:56:35 +0200 (CEST) From: Andreas Kretschmer Reply-To: Andreas Kretschmer To: Matthias Nagel , pgsql-sql@postgresql.org Message-ID: <1237868969.148407.1348916195838.JavaMail.open-xchange@ox.ims-firmen.de> In-Reply-To: <43516431.HfO3TYfNBy@hek506> References: <43516431.HfO3TYfNBy@hek506> Subject: Re: Reuse temporary calculation results in an SQL update query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v6.20.6-Rev4 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201209/58 X-Sequence-Number: 36860 Matthias Nagel hat am 29. September 2012 um 12:49 geschrieben: > Hello, > > is there any way how one can store the result of a time-consuming calculation > if this result is needed more than once in an SQL update query? This solution > might be PostgreSQL specific and not standard SQL compliant. Here is an > example of what I want: > > UPDATE table1 SET > StartTime = 'time consuming calculation 1', > StopTime = 'time consuming calculation 2', > Duration = 'time consuming calculation 2' - 'time consuming calculation 1' > WHERE foo; The Duration - field is superfluous ... As far as i know there is no way to re-use the result. Regards, Andreas