Thread: Concatenation in SELECT

Concatenation in SELECT

From
Alex
Date:
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

From
Manfred Koizar
Date:
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