Reference column alias for common expressions

From: Wood May <asdf_pg(at)outlook(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Reference column alias for common expressions
Date: 2022-05-24 15:12:21
Message-ID: KL1PR0601MB3921757C9EBCDCEBC575024184D79@KL1PR0601MB3921.apcprd06.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
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?

Thanks a lot!

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2022-05-24 15:28:20 Improving connection scalability (src/backend/storage/ipc/procarray.c)
Previous Message Robert Haas 2022-05-24 15:05:23 Re: Shmem queue is not flushed if receiver is not yet attached