Re: Constructing column from different individual fields in

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Alex Martinoff <froggle2003(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Constructing column from different individual fields in
Date: 2003-09-10 15:44:28
Message-ID: 200309101544.h8AFiSO01239@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruno Wolff III wrote:
> On Tue, Sep 09, 2003 at 21:02:21 -0700,
> Alex Martinoff <froggle2003(at)yahoo(dot)com> wrote:
> > I'm wondering if it's possible to have a query construct a column
> > where the value of the column at each row is taken from another field
> > in that same row. For example, suppose you have a table like:
>
> You can use CASE to do this.

You can also use UNION:

SELECT col1 ...
UNION
SELECT col2 ...

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Network Administrator 2003-09-10 16:10:45 Re: Picture with Postgres and Delphi
Previous Message expect 2003-09-10 15:43:49 Re: SUMMARY mysql -> psql