From: | "Tchouante, Merlin" <mtchouan(at)umaryland(dot)edu> |
---|---|
To: | JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | RE: Query with conditional statement |
Date: | 2023-09-13 17:57:54 |
Message-ID: | DM4PR12MB511902103147E02227761C66D2F0A@DM4PR12MB5119.namprd12.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Yes, it can.
Thanks,
-- Merlin
Merlin D. Tchouante, Sr. IT Enterprise Application Developer
Center for Information Technology Services (CITS)
601 West Lombard Street
Baltimore, Maryland 21201-1512
mtchouan(at)umaryland(dot)edu<mailto:mtchouan(at)umaryland(dot)edu>
410-706-4489 * 410-706-1500 fax
Please send Blackboard questions to the CITS support email address: DL-CITSBbSupport(at)umaryland(dot)edu<mailto:dl-citsbbsupport(at)umaryland(dot)edu>
Please send Mediasite questions to the CITS support email address: DL-CITSMediasiteSupport(at)umaryland(dot)edu<mailto:DL-CITSMediasiteSupport(at)umaryland(dot)edu>
[cid:image001(dot)png(at)01D9E64A(dot)49E98770]
From: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
Sent: Wednesday, September 13, 2023 1:52 PM
To: pgsql-sql(at)postgresql(dot)org
Subject: Query with conditional statement
You don't often get email from jorgemal1960(at)gmail(dot)com<mailto:jorgemal1960(at)gmail(dot)com>. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
CAUTION: This message originated from a non-UMB email system. Hover over any links before clicking and use caution opening attachments.
Hi,
Can a conditional CASE statement be part of the SELECT portion of a query? For example:
SELECT
fld1, fld2, fld3,
CASE
WHEN condition1 THEN fldx1 AS a1, fldx2 AS a2, fldx3 AS a3
WHEN condition2 THEN fldy1 AS b1, fldy2 AS b2, fldy3 AS b3
ELSE .....
END,
fld6, fld7
FROM ......
WHERE ......
I ran a test and see the following:
* Each WHEN only accepts 1 result and not 3 as shown in the example
* The AS for the alias is not supported
I need to return more than 1 field on each WHEN and also assign an ALIAS.
I very much appreciate your feedback.
Regards,
Jorge Maldonado
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2023-09-13 18:07:05 | Re: Query with conditional statement |
Previous Message | JORGE MALDONADO | 2023-09-13 17:52:18 | Query with conditional statement |