Re: Add one column to another - Mailing list pgsql-sql

From Tim Landscheidt
Subject Re: Add one column to another
Date
Msg-id m3vctlqt2h.fsf@passepartout.tim-landscheidt.de
Whole thread Raw
In response to Add one column to another  (gvim <gvimrc@gmail.com>)
List pgsql-sql
(anonymous) wrote:

> I have to deal with a table which contains:

> first_name
> surname
> email1
> email2

> ... and I would like to create a view which combines both email columns thus:

> first_name
> surname
> email

> It looks simple but I can't think of an obvious query.

Try:

| SELECT first_name, surname, email1 AS email FROM testtable WHERE email1 IS NOT NULL UNION ALL
| SELECT first_name, surname, email2 AS email FROM testtable WHERE email2 IS NOT NULL;

Tim



pgsql-sql by date:

Previous
From: "David Johnston"
Date:
Subject: Re: Add one column to another
Next
From: Scott Marlowe
Date:
Subject: Re: Add one column to another