Обсуждение: Concatenation in SELECT

Поиск
Список
Период
Сортировка

Concatenation in SELECT

От
Alex
Дата:
Hi,
is it possible to concatenate two rows (same or different data type)
into one.
like First Name, Last Name   or ZIP City  etc.

Thanks
Alex



Re: Concatenation in SELECT

От
Manfred Koizar
Дата:
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