Re: Query with conditional statement

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: JORGE MALDONADO <jorgemal1960@gmail.com>
Cc: pgsql-sql@postgresql.org
Date: 2023-09-13T18:07:05Z
Lists: pgsql-sql
On Wed, Sep 13, 2023 at 10:53 AM JORGE MALDONADO <jorgemal1960@gmail.com>
wrote:

> I need to return more than 1 field on each WHEN and also assign an ALIAS.
>
>
You can only produce a single value of a specific data type from the output
of a case expression.   To do what you desire, create a custom composite
type and return that.  You get to name the fields when you define the
composite type.

David J.