Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ml7yx-0003co-PA for pgsql-sql@arkaria.postgresql.org; Thu, 11 Nov 2021 11:11:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ml7yw-0000iN-A5 for pgsql-sql@arkaria.postgresql.org; Thu, 11 Nov 2021 11:11:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ml7yv-0000iE-BC for pgsql-sql@lists.postgresql.org; Thu, 11 Nov 2021 11:11:02 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ml7yo-0006ru-JR for pgsql-sql@lists.postgresql.org; Thu, 11 Nov 2021 11:11:00 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id C4F863201126; Thu, 11 Nov 2021 06:10:51 -0500 (EST) Received: from imap43 ([10.202.2.93]) by compute6.internal (MEProxy); Thu, 11 Nov 2021 06:10:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type; s=fm1; bh=vgkJrTqwYAqz72Eq5UbZPF6CpxsoL0E pfVknzA4Z5sE=; b=LiE1Bs+rWTJx1pF/dIIO1HJ4RjWjjGH0cgOpnreOsnHgfLX P5xNWRprxjG5kYyEr8MkdTMarRbG+2EUZAXPvQ4O2Bn1mlyA2Y/zEL4VVeOeOb4g WIOUdcxZHukSgakR4j9fQg7Nc2qRxWVknD07KXvBLxq2TMy7YSxCCkKvnr4T0T/T UFQWMRqY2jNzaX7r8PiNM6DVs1LD947yaHQlkQ8ccR1KMT/Bf03f+J6BhY+h4x5E F8OwqKB0yWSKDBsoVYJokKacLIn+7mYM/vj7wFk1zKsMJ/8RszvlqDcxM6XYCyPw 6cXVRqlOIh9oSsnGRfklcRgcD4wsPBHERDbOOTg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=vgkJrT qwYAqz72Eq5UbZPF6CpxsoL0EpfVknzA4Z5sE=; b=hjTgw0Zjm/dObUK/t7bxek je253Fu2ZsE3k4cin0Gpv1MFV/ic6UUUqBfiPv2sJYCCXRDLsbZccgmI9bcyeKPU QC0donIf3vfUYYFC9NF7aCXHaMSN7lIivGWiDAwxpA/Q9Ah94iGWZZQ/WaiOEc+F tYT+7XPI/aDVjEiJ4cyJcYMr6wN32w7QELJCVuRtRlOq4Dw1H0y01wK+lONc9QYd Yio879+jbmMCP0sEEAz05zj8tnris03Si7sZglC7D2/wSl9Y/TJ9slmDTTFNR3gR C4LqbuoT8FgQW3xJByISItSrcAtSAXK79yJQ8lEDWD2LKv5Kj8jk5efMHGBiGwPw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrvddugddvhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesrgdtre erreerjeenucfhrhhomhepfdfvohhrshhtvghnucfirhhushhtfdcuoehtvghgghihsehf rghsthhmrghilhdrtghomheqnecuggftrfgrthhtvghrnhephfdugfelheefleetkefhvd etveeikeekjeduueffhfdvjefgueduuedvleevveeunecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomhepthgvghhghiesfhgrshhtmhgrihhlrdgtoh hm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 45117AC0DD1; Thu, 11 Nov 2021 06:10:51 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-1371-g2296cc3491-fm-20211109.003-g2296cc34 Mime-Version: 1.0 Message-Id: In-Reply-To: References: Date: Thu, 11 Nov 2021 12:10:31 +0100 From: "Torsten Grust" To: "aditya desai" , pgsql-sql Subject: Re: Constructing colum name as alias Content-Type: multipart/alternative; boundary=38bff7d6b671407cba1fe2234d7dbeda List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --38bff7d6b671407cba1fe2234d7dbeda Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, since column names (or table names) are not first-class values in SQL, c= omputing such names at query runtime is impossible. Best wishes, =20 =E2=80=94Torsten 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. >=20 > postgres=3D# Select ('Status as on '||date_part('day', (SELECT current= _timestamp))||'th '||TO_CHAR(current_timestamp, 'Mon')) > postgres-# ; > ?column? > ----------------------- > Status as on 11th Nov >=20 > " Status as on 11th Nov" should be my column name in a query. >=20 > SELECT JoiningDate as "Status as on 11th Nov" from empdetails; >=20 > How can I achieve this? >=20 > Regards, > Aditya. >=20 -- | Torsten Grust | teggy@fastmail.com --38bff7d6b671407cba1fe2234d7dbeda Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi,

since column names (or table names) are not first-clas= s values in SQL, computing such names at query runtime is impossible.

Best wishes,  
   =E2= =80=94Torsten

On Thu, Nov 11, 2021, at 08:4= 6, aditya desai wrote:
Hi,
I want to construct column na= me alias by using different queries. E.g. below.

postgres=3D# Select ('Status as on '||date_part('day', (SELEC= T current_timestamp))||'th '||TO_CHAR(current_timestamp, 'Mon'))
postgres-# ;
       ?column?
-----------------------
 Status as on 11t= h Nov

" Status as on 11th Nov" should= be my column name in a query.

SELECT Joini= ngDate as "Status as on 11th Nov" from empdetails;

How can I achieve this?

Regard= s,
Aditya.


--
| Torsten Grust
<= div class=3D"signature">| teggy@fastmail.com
=


--38bff7d6b671407cba1fe2234d7dbeda--