Re: Concatenation in SELECT

Поиск
Список
Период
Сортировка
От Manfred Koizar
Тема Re: Concatenation in SELECT
Дата
Msg-id dv5srvom8fi7vog260mun6oukreh3cu78r@email.aon.at
обсуждение исходный текст
Ответ на Concatenation in SELECT  (Alex <alex@meerkatsoft.com>)
Список pgsql-general
On Fri, 21 Nov 2003 20:22:17 +0900, Alex <alex@meerkatsoft.com> wrote:
>Hi,
>is it possible to concatenate two rows (same or different data type)
>into one.
>like First Name, Last Name   or ZIP City  etc.

If you meant to concatenate two *columns*, it goes like

    SELECT firstname || ' ' || lastname AS fullname FROM ...

or for nullable columns

    SELECT coalasce(firstname || ' ', '') ||
           coalesce(lastname, '') AS ...

This should work for non-text datatypes as well, because most, if not
all, datatypes have implicit casts to text.

Servus
 Manfred

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

Предыдущее
От: Denis Gasparin
Дата:
Сообщение: Bug in pg_dumpall
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: tsearch2 column update produces "word too long"