Query with conditional statement

Поиск
Список
Период
Сортировка
От JORGE MALDONADO
Тема Query with conditional statement
Дата
Msg-id CAAY=A78qufOUD+GLZVjNwLgBer2DxtJsHrc3h7H8r33_yuhrTw@mail.gmail.com
обсуждение исходный текст
Ответы RE: Query with conditional statement  ("Tchouante, Merlin" <mtchouan@umaryland.edu>)
Re: Query with conditional statement  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-sql
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

В списке pgsql-sql по дате отправления:

Предыдущее
От: "Mike Sofen"
Дата:
Сообщение: RE: How to handle application connectivity change when moving from Oracle to Postgres in GCP
Следующее
От: "Tchouante, Merlin"
Дата:
Сообщение: RE: Query with conditional statement