Let-bindings in SQL statements - Mailing list pgsql-general

From Jon Smark
Subject Let-bindings in SQL statements
Date
Msg-id 1327588669.84153.YahooMailNeo@web112810.mail.gq1.yahoo.com
Whole thread Raw
Responses Re: Let-bindings in SQL statements  (Szymon Guz <mabewlun@gmail.com>)
Re: Let-bindings in SQL statements  ("David Johnston" <polobo@yahoo.com>)
Re: Let-bindings in SQL statements  (David W Noon <dwnoon@ntlworld.com>)
Re: Let-bindings in SQL statements  (Filip Rembiałkowski <plk.zuber@gmail.com>)
List pgsql-general
Hi,

Is it possible to do the equivalent of let-bindings in a pure SQL function?
I have a SELECT that invokes "now" multiple times.  It would be nicer
to do it only once and reuse the value.  Something like this:

LET right_now = SELECT now () IN
SELECT * FROM my_table WHERE right_now >= start AND ...

In PL/pgSQL this is easy, but I wonder about SQL...

Thanks in advance!
Jon

pgsql-general by date:

Previous
From: salah jubeh
Date:
Subject: How to push predicate down
Next
From: Szymon Guz
Date:
Subject: Re: Let-bindings in SQL statements