From: | Matthias Nagel <matthias(dot)h(dot)nagel(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Reuse temporary calculation results in an SQL update query |
Date: | 2012-09-29 10:49:18 |
Message-ID: | 43516431.HfO3TYfNBy@hek506 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 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;
It would be nice, if I could use the "new" start and stop time to calculate the duration time. First of all it would make the 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(dot)h(dot)nagel(at)gmail(dot)com
ICQ: 499797758
Skype: nagmat84
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2012-09-29 10:55:39 | Re: Reuse temporary calculation results in an SQL update query |
Previous Message | mephysto | 2012-09-27 10:12:21 | Help in accessing array |