Re: Constructing colum name as alias

From: chris <yuanzefuwater(at)126(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "aditya desai" <admad123(at)gmail(dot)com>, pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>, "stercor(at)gmail(dot)com" <stercor(at)gmail(dot)com>
Subject: Re: Constructing colum name as alias
Date: 2021-11-11 14:23:57
Message-ID: 18007723.72e9.17d0f62427a.Coremail.yuanzefuwater@126.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

A flexible way to application, don’t know the actually value🤦‍♂️ see below:

select * from (Select ('Status as on '||date_part('day', (SELECT current_timestamp))||'th '||TO_CHAR(current_timestamp, 'Mon'))
union all
select now()::text from t1) foo limit 11;

Regards,
Chris
On 11/11/2021 22:16,David G. Johnston<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
On Thu, Nov 11, 2021 at 7:14 AM David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

On Thu, Nov 11, 2021 at 6:23 AM Theodore M Rolle, Jr. <stercor(at)gmail(dot)com> wrote:

May we have an example?

Here are the docs detailing writing dynamic SQL commands in pl/pgsql.

https://www.postgresql.org/docs/current/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

Though, as you probably want to see these columns in your application you will probably need to translate the concept to whatever programming language and database client interface you are using.

David J.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message aditya desai 2021-11-16 17:10:08 SELECT on view runs slower with more WHERE conditions
Previous Message David G. Johnston 2021-11-11 14:16:12 Re: Constructing colum name as alias