Re: Reference column alias for common expressions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Wood May <asdf_pg(at)outlook(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Reference column alias for common expressions
Date: 2022-05-24 16:03:42
Message-ID: 1651063.1653408222@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Wood May <asdf_pg(at)outlook(dot)com> writes:
> Some databases (like Teradata) support the following syntax:
> select col1, col2*20 as col2_1, col2_1*200 as col3_1 from your_table;
> The last element in the target list can refer the second one using its alias.
> This feature is similar to some programming languages (like Lisp)'s let*​.
> For Postgres, it seems the only way is to write a subquery and then a new target list.

> Will Postgres plan to support this feature?

No. It's flat out contrary to the SQL standard.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-05-24 16:06:43 Re: Improving connection scalability (src/backend/storage/ipc/procarray.c)
Previous Message Tom Lane 2022-05-24 16:01:58 Re: PG15 beta1 sort performance regression due to Generation context change