Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qgUH0-00FzX1-I4 for pgsql-sql@arkaria.postgresql.org; Wed, 13 Sep 2023 18:07:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qgUGy-001SYF-5c for pgsql-sql@arkaria.postgresql.org; Wed, 13 Sep 2023 18:07:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qgUGx-001SXf-OZ for pgsql-sql@lists.postgresql.org; Wed, 13 Sep 2023 18:07:31 +0000 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qgUGq-004NCF-5C for pgsql-sql@postgresql.org; Wed, 13 Sep 2023 18:07:30 +0000 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-1c8d895a602so67787fac.2 for ; Wed, 13 Sep 2023 11:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694628443; x=1695233243; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=DcldAW8HVZSmMPFFbyNwKrVXl3GWMz/UOD/h0VI6Pac=; b=ae+7/NtXJ4T/mwiLMMxv1V7p8f3YpJwR0hxr6040nQtuiPFhZ/j3bnlOiqL6xy1wTr wY/2bYYhfVhghdLOml4jK/1DeA+BpYzXUA/uREii3OuR6UbIgIihX0GdJOkINfXUFkY+ OMzWKkeOo2V78vkTHroBnU13RrdYhY2++3BOjBlK92ZXCFT+ZZpAS9dqBFwWv0WZS9Md 3QQEV0VWXV8F3zB2G+AYv/AXu4/ZjCYs20xt6WdFNn/QAcllfBIPey8NO+cIfIeLI4+a U2NQ4/yGN4no9nnHcut28h0HDIEFvAhLk3KydSEAtGRORXxXvt2fkvI7Zov0BXN9vCvn hhyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694628443; x=1695233243; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DcldAW8HVZSmMPFFbyNwKrVXl3GWMz/UOD/h0VI6Pac=; b=YUdxlqP8vonZ6AJ3Y9KEJWwUE/kFHdlznKzuocIDb57R1veP45/mI4CUAuCQgnVfnB nVQg2KP4o8ZbYthvSdBPW0QJzou8ibrVZmS1EztyfsQkT6NvPa1E3frqryljxucfWKMH o+J/q6qJApMeqaVY2f0D2tsF2RCnB7AUSZZ9ZiYsgCk9HSwgzGRfj4o/XSJHQdplHpdx Kx0uil8bJ3QcFmh+0BFjn1vsP8vhC+IUNIK+2npveTbb1kWw/TEbhrpJlfjf/SzJm32H QxF3YdioWwrj547A9TggZPcCcpM6DVTK0k+03ieBZ+5OUftSJH4038c80oF3vuTQu/LJ AA+A== X-Gm-Message-State: AOJu0YwzNOtNGjWCHuIX9Zyu8SGybre5Ge7R0EVR1zMuwLgMej32DL6V OuszgW8gp50/2cHxES7EbhcERXb93I9Kwzfu28g= X-Google-Smtp-Source: AGHT+IEdI+enNRKbiy/K/Q+wejO5Eq+ffxZvxd6KlcmRJWseOg+8yn4dP930AeD4KDRxU2c5ltU5kVdcqzJNnd4R2U8= X-Received: by 2002:a05:6870:4721:b0:1d4:d5a8:3d1a with SMTP id b33-20020a056870472100b001d4d5a83d1amr3646004oaq.30.1694628443133; Wed, 13 Sep 2023 11:07:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "David G. Johnston" Date: Wed, 13 Sep 2023 11:07:05 -0700 Message-ID: Subject: Re: Query with conditional statement To: JORGE MALDONADO Cc: pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary="000000000000611af90605416e62" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000611af90605416e62 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Sep 13, 2023 at 10:53=E2=80=AFAM JORGE MALDONADO 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. --000000000000611af90605416e62 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Sep 13, 2023 at 10:53=E2=80=AFAM JORGE MALDONADO &= lt;jorgemal1960@gmail.com>= wrote:
I need to return more tha= n 1 field on each WHEN and also assign an ALIAS.

=

You can only produce a single value of a spe= cific data type from the output of a case expression.=C2=A0 =C2=A0To do wha= t you desire, create a custom composite type and return that.=C2=A0 You get= to name the fields when you define the composite type.

<= div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-serif= ">David J.

--000000000000611af90605416e62--