table unions

From: "Wright, George" <George(dot)Wright(at)infimatic(dot)com>
To: "pgsql" <pgsql-novice(at)postgresql(dot)org>
Subject: table unions
Date: 2008-08-08 15:13:34
Message-ID: 51548D6D5BEB57468163194A8C1A0E980161A35B@MAGPTCPEXC02.na.mag-ias.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Novice question:

How can I apply conditional logic when doing a union of two tables?

TableA TableB
------ ------
value1 value2 value1 value2
1 10 5 15
11 20

SELECT * FROM TableA UNION SELECT * FROM TableB;
returns:

value1 value2
1 10
5 15
11 20

what I want is

value1 value2
1 5
5 15
15 20

The tables are huge and already in ascending order.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Sean Davis 2008-08-08 15:49:58 Re: table unions
Previous Message Peter Jackson 2008-08-08 14:32:22 Re: join group by etc