agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Torsten Grust <teggy@fastmail.com>
To: aditya desai <admad123@gmail.com>
To: pgsql-sql <pgsql-sql@lists.postgresql.org>
Subject: Re: Constructing colum name as alias
Date: Thu, 11 Nov 2021 12:10:31 +0100
Message-ID: <b2f18b45-c908-4c57-9a52-5bbc3dceed03@www.fastmail.com> (raw)
In-Reply-To: <CAN0SRDH0DhD=WUCbyZ6mG9XGbEyuTaTvaMqoBZc_++7uNxpvrg@mail.gmail.com>
References: <CAN0SRDH0DhD=WUCbyZ6mG9XGbEyuTaTvaMqoBZc_++7uNxpvrg@mail.gmail.com>
Hi,
since column names (or table names) are not first-class values in SQL, computing such names at query runtime is impossible.
Best wishes,
—Torsten
On Thu, Nov 11, 2021, at 08:46, aditya desai wrote:
> Hi,
> I want to construct column name alias by using different queries. E.g. below.
>
> postgres=# Select ('Status as on '||date_part('day', (SELECT current_timestamp))||'th '||TO_CHAR(current_timestamp, 'Mon'))
> postgres-# ;
> ?column?
> -----------------------
> Status as on 11th Nov
>
> " Status as on 11th Nov" should be my column name in a query.
>
> SELECT JoiningDate as "Status as on 11th Nov" from empdetails;
>
> How can I achieve this?
>
> Regards,
> Aditya.
>
--
| Torsten Grust
| teggy@fastmail.com
view thread (7+ messages) latest in thread
Message-ID: <b2f18b45-c908-4c57-9a52-5bbc3dceed03@www.fastmail.com>
Permalink: ../b2f18b45-c908-4c57-9a52-5bbc3dceed03@www.fastmail.com/
Also on: postgresql.org/message-id/b2f18b45-c908-4c57-9a52-5bbc3dceed03@www.fastmail.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: teggy@fastmail.com, admad123@gmail.com, pgsql-sql@lists.postgresql.org
Subject: Re: Constructing colum name as alias
In-Reply-To: <b2f18b45-c908-4c57-9a52-5bbc3dceed03@www.fastmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox