Reuse temporary calculation results in an SQL update query - Mailing list pgsql-sql

Hello,

is there any way how one can store the result of a time-consuming calculation if this result is needed more than once
inan SQL update query? This solution might be PostgreSQL specific and not standard SQL compliant. Here is an example of
whatI want:
 

UPDATE table1 SET  StartTime = 'time consuming calculation 1',  StopTime = 'time consuming calculation 2',  Duration =
'timeconsuming calculation 2' - 'time consuming calculation 1'
 
WHERE foo;

It would be nice, if I could use the "new" start and stop time to calculate the duration time. First of all it would
makethe SQL statement faster and secondly much more cleaner and easily to understand.
 

Best regards, Matthias

----------------------------------------------------------------------
Matthias Nagel
Willy-Andreas-Allee 1, Zimmer 506
76131 Karlsruhe

Telefon: +49-721-8695-1506
Mobil: +49-151-15998774
e-Mail: matthias.h.nagel@gmail.com
ICQ: 499797758
Skype: nagmat84




pgsql-sql by date:

Previous
From: "Abhijit Prusty -X (abprusty - UST Global at Cisco)"
Date:
Subject: HOw to convert unicode to string
Next
From: Andreas Kretschmer
Date:
Subject: Re: Reuse temporary calculation results in an SQL update query